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

add invalidating to lazyObservable #20

Merged
merged 3 commits into from
Nov 1, 2016
Merged

Conversation

thinhvoxuan
Copy link
Contributor

lazyObserable sometimes need trigger to loading new data such as after edit profile, I need to run '/loadProfile' again

lazyObserable sometimes need trigger to loading new data such as after edit profile, I need to run '/loadProfile' again
@mweststrate
Copy link
Member

Thanks for the PR, looks useful!

Shouldn't it be called invalidate()? could you add unit tests as well?

Thanks!

add testcase for refresh case
@thinhvoxuan
Copy link
Contributor Author

@mweststrate I name that function is 'refresh' instead of 'invalidate'. I also add test-case for refresh function but I never work. Could you give me any clue?

@mweststrate
Copy link
Member

@voxuanthinh I think your implementation is correct, but you use a Promise in your test,and promises are not replayable, so you cannot test this behavior using Promises, a new then call will just resolve the already resolved value. You could test this by creating a new Promise each time instead:

sink => new Promise((resolve, reject) => {
        started = started + 1;
        resolve(i);
        i++;
    }).then(value =>  {
        sink(value)
    }),

@coveralls
Copy link

coveralls commented Nov 1, 2016

Coverage Status

Coverage decreased (-0.3%) to 97.248% when pulling 057a9ae on voxuanthinh:master into ca9a1af on mobxjs:master.

@thinhvoxuan
Copy link
Contributor Author

@mweststrate :) nice. thank.

@mweststrate mweststrate merged commit 14c0082 into mobxjs:master Nov 1, 2016
@mweststrate
Copy link
Member

Released as 1.1.2

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.

3 participants