Skip to content

Commit

Permalink
fview.autorun()
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Jun 6, 2015
1 parent 1038da2 commit 8270ca8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fix for Famous 0.5.2 (and further work on DOMElement handling)
* Initial child cleanup handling
* Support components that don't add themselves to the node + set `_id`
* `fview.autorun()` like tplOrView.autorun() in Meteor/Blaze; this = fview

* Fix wrapper with no args' renderFunc using `with` data as args
* famousEach, in a totally new and extensible way
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,22 @@ expect. See the live demos for some examples.
* `FView.current()` - great new shortcut for inside helpers, Meteor events,
template/view autoruns and some callbacks. Uses `Blaze.currentView` internally.

## fview (node/etc instance)

**Properties**

* `fview.id`
* `fview.node` - the node instance
* `fview.components` - dictionary of data for added components
* `fview.fvClass` - class data
* `fview.*` - misc other stuff depending on the node type/class

**Methods**

* `fview.autorun(func)` -- just like `tplOrView.autorun` in Meteor/Blaze except
`this` in the callback will be the `fview`; automatically removed when node
is destroyed.

## Wrap your Own

Just as with v0, famous-views is primarily a low-level wrapper around Famous,
Expand Down
6 changes: 6 additions & 0 deletions lib/wrappers/Nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ var NodeClass = FView._NodeClass = {
fview.node = fvClass.newInstance.call(fview);
fview.fvClass.addToParent.call(fview);

fview.autorun = function(func) {
blazeView.autorun(function() {
func.call(fview);
});
};

var viewToRender;
if (blazeView.parentView && blazeView.parentView.__isTemplateWith) {
viewToRender = Blaze._TemplateWith(
Expand Down

0 comments on commit 8270ca8

Please sign in to comment.