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

waitfor array #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

waitfor array #202

wants to merge 1 commit into from

Conversation

RickButler
Copy link
Collaborator

@RickButler RickButler commented Oct 13, 2018

Add the ability to use an array of string paths for waitFor.

some random things included in this:
remove unused require statements
normalize spacing around function declarations

@RickButler
Copy link
Collaborator Author

RickButler commented Oct 29, 2018

I'm constantly creating derived properties to test for successful fetching of data before rendering a subview.

for example I will have a view with two models (or more).

children: {
    exampleModelOne: MyModel,
    exampleModelTwo: MyModel
}

I have properties that I set when they have been fetched . I then have a derived listening to these props.

derived: {
    viewReady: {
        deps: ['exampleModelOne.fetched', 'exampleModelTwo.fetched'],
        fn: function () { return this.exampleModelOne.fetched && this.exampleModelTwo.fetched; }
}

and then:

subview: {
    myStuff: {
        selector: '[data-hook=collection-container]',
        waitFor: 'viewReady',
        prepareView: function (el) { //do stuff }
    }
}

This would allow skipping the derived and instead just using multiple waitFor:

subview: {
    myStuff: {
        selector: '[data-hook=collection-container]',
        waitFor: ['exampleModelOne.fetched', exampleModelTwo.fetched],
        prepareView: function (el) { //do stuff }
    }
}

The overhead for this would be no worse than creating the derived, the average case may event be better because once 'action' gets called it removes the event listener, instead of the derived catching changes for its deps and any other overall "change" events for the entire lifecycle of the view.

Looking for someone else to sign off on this since I wrote it, @dhritzkiv if you have some time maybe?

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

Successfully merging this pull request may close these issues.

1 participant