🌲
Spruce
  • Introduction
  • Installation
  • Quick Start
  • The Essentials
  • Stores
  • Watchers
  • Persistence
  • Advanced
    • Hooks
  • Examples
    • Global Toast System
  • More
    • GitHub
    • Funding
    • Security
    • License
Powered by GitBook
On this page
  • Spruce.starting()
  • Spruce.started()

Was this helpful?

  1. Advanced

Hooks

Learn how to hook into the Spruce lifecycle.

Spruce goes through various steps during it's lifecycle on a website. Hooks can be used to execute code at certain points in Spruce's execution cycle.

Spruce.starting()

This hook can be used to invoke a function before Spruce has fully initialised and before any global stores are being watched.

Spruce.starting(function () {
    console.log('Spruce is starting...')
})

Spruce.started()

This hook can be used to invoke a function after Spruce has fully initialised and after any global stores are being watched.

Spruce.started(function () {
    console.log('I can access Proxy instances here...')
})

You can register multiple functions via these hooks. They will be executed in the order they were registered.

PreviousPersistenceNextGlobal Toast System

Last updated 4 years ago

Was this helpful?