Skip to content

Commit

Permalink
Docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Feb 14, 2017
1 parent 09777cc commit 4e79284
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ We've made some changes to make observable selectors more convenient. None of th

### Added `component.isMounted()` API

As we roll out increased support for dynamic mounting, knowing whether or not a component is currently mounted becomes increasingly relevant. In previous versions this could be checked by looking for the `__mounted` internal variable on the component instance (which is now deprecated)

There is now a `component.isMounted()` API which returns true when the component is mounted and false otherwise.

## 0.3.0
Expand Down
8 changes: 5 additions & 3 deletions docs/API/mountComponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

## State tree design

Broadly speaking, there are two ways to manage your Redux state tree using redux-components. You can let redux-components manage the root of your tree (as well as all subnodes) or your state tree can be managed manually, with redux-components being mounted at one or more subnodes of the state tree.
Broadly speaking, there are two ways to manage your Redux state tree using redux-components. You can let redux-components manage the root of your tree, or your state tree can be managed manually, with redux-components being mounted at one or more subnodes of the state tree.

We discuss both of these cases.
Note that even if you let redux-components manage your root node, you can still attach any reducer you want, including reducers from external libraries, to nodes beneath your root node. For ease of use, we recommend letting redux-components manage your root node.

We discuss both cases below.

### redux-component at the root

Expand Down Expand Up @@ -37,7 +39,7 @@ store = createStore( (x) -> x )
mountRootComponent(store, rootComponent)
```

> * When using this approach, you can still attach reducers not managed by redux-components to nodes of your state tree beneath the root. Use `SubtreeMixin`.
> * When using this approach, you can still attach reducers not managed by redux-components to nodes of your state tree beneath the root. Use `SubtreeMixin` or `redux-components-map`.
### Manual mounting

Expand Down
10 changes: 4 additions & 6 deletions docs/Advanced/ObservableSelector.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Redux 3.6.x adds the ability for Stores to function as [ES7 Observables](https:/

## Functionality

Observable selectors are provided by adding the `ObservableSelectorMixin` to your component class:
When declaring a class, any functions specified under the `selectors` key will automatically be converted into ES7 Observables:

```coffeescript
{ ObservableSelectorMixin, createClass } = require 'redux-components'
{ createClass } = require 'redux-components'

MyClass = createClass {
mixins: [ ObservableSelectorMixin ]
...
selectors: {
mySelector: (state) -> state.myValue
Expand All @@ -18,8 +18,6 @@ MyClass = createClass {
}
```

Behind the scenes, this mixin ensures that when an instance of your component is mounted, all of the `selectors` on the instance will be augmented to conform to the [ES7 Observable](https://github.com/tc39/proposal-observable) pattern.

Here are the details:

- To watch an observable selector for changes, you call the `subscribe(Observer)` method on the selector, passing an object that conforms to the ES7 `Observer` interface. The `subscribe` method returns an ES7 `Subscription` object that can be used to unsubscribe later.
Expand All @@ -37,4 +35,4 @@ subscription.unsubscribe()

- Observable selectors assume conformance with the Redux contract, and therefore use identity (`===`) comparison to detect changes. Your Redux stores are expected to return unequal objects when changes are made.

- Your component must be mounted to a store before you may subscribe to observable selectors. (This means, inter alia, that while inside a component's `componentWillMount` method, you cannot observe the selectors of that component. You must wait until `componentDidMount`.)
- Selectors are only active when a component is mounted. You may still attach an `Observer` to a selector even when a component is not mounted, but the `Observer` will not be attached until it is.

0 comments on commit 4e79284

Please sign in to comment.