Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Edit: Updated with current info
Description
I merged the implementations of
m.mount
andm.redraw
, I removed the intermediate route service fromm.route
, and I putm.mount
/m.redraw
in charge of actual throttling as it simplified a lot. I also reduced the scope of the dependencies being injected, so it's a little easier to test.Oh, and this makes it pretty clear that
m.route
could very easily be implemented in userland - it literally just depends onm.mount
andm.redraw
. Down this vein, I then updatedrender
to accept a newredraw
callback as a third parameter and movedm.mount
/m.redraw
to be implemented in terms of that, making that entirely agnostic of renderer.This reduces the bundle size to 9400 bytes min+gzip, where it was previously 9560. Small win, but that's not the main benefit of this.
Note that this now no longer exposes
redrawService
frommithril/redraw
and instead just exports theredraw
callback directly. So if you were previously usingmithril/redraw
, here's how you need to migrate:var redraw = require("mithril/redraw").redraw
→var redraw = require("mithril/redraw")
(drop the property access)redrawService.schedule
+redrawService.unschedule
→ Use components as necessary. If you need to do this away from the DOM for some reason, render to an element not kept in the live tree.redrawService.render
→ In general, this is the wrong thing to do. Just usem.redraw()
+ components as appropriate.Motivation and Context
This addresses a few long-standing issues us maintainers have talked about privately for a little over a year, and has been historically low-priority. It should also be a little easier to make sense of.
Fixes #2074 (requirement for #1907)
How Has This Been Tested?
I moved around a lot of tests and removed a couple duplicates.
Types of changes
Checklist:
docs/change-log.md