Skip to content

A Polymer behavior, implementing the co generator in Polymer

License

Notifications You must be signed in to change notification settings

kisira/co-behavior

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

co-behavior

A Polymer behavior, implementing the co generator in Polymer. co is implemented as a behavior. A simple way to use it is as part of a a polymer function as below:

Published on webcomponents.org

<link rel="import" href="co-behavior.html">
....

class SomeClass extends Polymer.mixinBehaviors(
            [                                                                
                Polymer.CoBehavior
            ], Polymer.Element) {

__fetchStuff() {
    var self = this;
    return new Promise(function(resolve, reject) {
        .....
        resolve(stuff);
    });
}

__fetchSomething() {
    let something = function*() {
        let stuff = yield this.__fetchStuff.call(this);            
        this.someProperty = stuff;            
    };
    return this.co(something.call(this));
}

Install with:

bower install co-behavior --save-dev

Read more about co and generators here

About

A Polymer behavior, implementing the co generator in Polymer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages