Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using more Promises ( finding ideas ) #37

Open
SerkanSipahi opened this issue Oct 5, 2016 · 0 comments
Open

Using more Promises ( finding ideas ) #37

SerkanSipahi opened this issue Oct 5, 2016 · 0 comments

Comments

@SerkanSipahi
Copy link
Owner

SerkanSipahi commented Oct 5, 2016

Ideas

@component()
@view(`
    <div class="foo">
         <com-loader></com-loader>
         <com-foo></com-foo>
    </div>
`)
class Foo {
    // fetch event bubbles over .loader an event with promise as value. 
    // If Promise resolved then onFetch will be called
    @on('fetch com-loader') @then onFetch({ result }) {

    }
    @on('ready com-foo') @then onReady({ result }){

    }
    // eventA, eventB and eventC send an promise through the event.
    // only when the promises (internal promise.all) resolved onAbc will be called
    @subscribe('eventA, eventB, eventC') @then onAbc({ resA, resB, resC }){

    }
}

// or
let component = Comfoo.create();
component.ready.then(() => {
    // awesome code
});

// or for subscriber
pubsub.publish('eventA', new Promise((resolve, reject) => setTimeout(resolve, 5000))); 
pubsub.publish('eventB', new Promise((resolve, reject) => setTimeout(resolve, 2000))); 
pubsub.publish('eventC', new Promise((resolve, reject) => setTimeout(resolve, 3000))); 
@SerkanSipahi SerkanSipahi changed the title Using more Promises in project Using more Promises ( finding ideas ) Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant