emce-select
v0.9.3
Published
Selecting parts of an Emce model
Downloads
1
Readme
Emce Select
A mixin for Emce to create an observable for part of the model.
Installation
Install from npm:
npm install emce-select --save
or
yarn add emce-select
Selecting
You pick out the part of the model you would like to observe. You will receive updates until that model is removed, then the observable will complete. If the model doesn't exist when selecting you will start receiving updates when the model gets a value.
You select by specifying which property of the model you want to watch. You can select sub-properties down to five levels.
emce.select('child').subscribe(...);
Alternatively you can specify a selector to get the part of the model that you want.
emce.select(selector).subscribe(...);
Selector (m: T) => U | null
The selector is a function that gets a child model. The selector can be used to create computed values of your model.
function(model: ExampleModel) {
return {
a: model.child,
b: model.otherchild
}
}