Skip to content

Commit

Permalink
Add clarification about init vs ready methods. See #141
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Nov 22, 2013
1 parent 13f39ab commit fb5b1b5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
1. [Mixins](#mixins)
1. [Init methods](#init-methods)
1. [Ready methods](#ready-methods)
1. [Init vs. Ready](#init-vs-ready)
1. [Destroy methods](#destroy-methods)

After creating a component, wire moves the component through its [lifecycle](concepts.md#component-lifecycle). During the *configure* lifecycle step, you can set properties on the component, and then during the *initialize* step that follows, you can invoke initialization methods to do further configuration, before [connections](connections.md) are made between components.
Expand Down Expand Up @@ -170,6 +171,12 @@ define({
});
```

# Init vs. Ready

While (init methods)[#init-methods] and (ready methods)[#ready-methods) sound similar (and they are), there is an important difference: their order in the component lifecycle. In short, a component's init methods are executed earlier than its ready methods.

To be more specific, init methods are executed *before* a component is allowed to be dereferenced--any attempt to dereference it will return a pending promise. This gives a component a chance to setup any necessary state or do any necessary work before any other components are allowed to inject or make connections to it.

# Destroy methods

In addition to init and ready methods, you can also specify methods to be invoked when a component is being [destroyed](concepts.md#component-lifecycle), to do any necessary cleanup, such as releasing resources used by the component, stopping timers, etc.
Expand Down

0 comments on commit fb5b1b5

Please sign in to comment.