-
-
Notifications
You must be signed in to change notification settings - Fork 924
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
Alternative request/redraw integration #1444
Alternative request/redraw integration #1444
Conversation
This doesn't look like the behavior quite matches what it's replacing. Currently Your version looks like it'll call |
My understanding is that that isn't an issue, since the redrawService is subscribed to in m.mount, which always defers the actual recomputation by some value of time. Sequential Promises chaining off the request will therefore always resolve before the actual view recomputation. Right? |
So after a bunch of discussion in gitter (starting about here) I think we ended up in agreement.
|
@tivac yep, AFAIC this patch fulfills these criteria. |
out of curiosity how do you guys determine the end of a promise chain? if |
@leeoniya The previous implementation wrapped the |
thanks, i suspected it wasn't a bare es6 promise. i understand how you can auto-chain the redraw. but still not how you can determine that the chaining is completed without an explicit external |
@barneycarroll this PR doesn't work; it redraws too early (run |
This raises a lot of awkward issues :/ @leeoniya is right, this relies on a decorated promise implementation and assigns dubious semantics to it. A promise can be forked, chained, passed to other contexts. A receiving context from one of these forks may well sit on that promise reference until an arbitrary condition resolves and only then declare a dependency upon it. The idea that Mithril can determine when the chain ends is fallacious. The magic interpretation of intent involved here is too high: either a request should always trigger a redraw on resolution, or never. Anything in between is too difficult to reason about, and therefore not a viable convenience feature. I think the desired intent of this patch is good - ie, you will get an async redraw as a result of requests and event handlers settling. Advanced users can opt out, after all - in component code or by building their own non-auto Mithril (at their own peril). What do we reckon? |
@barneycarroll This is why I don't want There's always |
it works like this now: https://github.com/lhorie/mithril.js/blob/rewrite/request/tests/test-request.js#L301-L317 Standalone has no redraw semantics |
This is a proposal relating to #1442. It allows
redraw: false
to be passed as an option tom.request
when using bundled Mithril in a way that addresses @lhorie's concern that this would on the face of it be too tight a coupling between the request API to the render API - this does it in such a way that request is actually more generic, and isolates the request/redraw hooks to the bundling module.It's difficult to write tests for this feature - I'm stymied by the fact that AFAICT I'd need to invoke both the piecemeal xhr & mock modules to test the bundled module - and I'm not sure how to do that.
Having said that, there were no tests for request/redraw integration in the first place, and this does pass all existing tests.