improve docs re: redraw
This commit is contained in:
parent
82ebff4336
commit
1d8021500a
2 changed files with 4 additions and 2 deletions
|
|
@ -89,7 +89,7 @@ m.route(document.body, "/", {
|
|||
|
||||
### When Mithril does not redraws
|
||||
|
||||
Mithril does not redraw after 3rd party library event handlers. In those cases, you must manually call [`m.redraw()`](redraw.md).
|
||||
Mithril does not redraw after `setTimeout`, `setInterval`, `requestAnimationFrame` and 3rd party library event handlers (e.g. Socket.io callbacks). In those cases, you must manually call [`m.redraw()`](redraw.md).
|
||||
|
||||
Mithril also does not redraw after lifecycle methods. This is because lifecycle methods run within the redraw cycle and allowing a nested redraw to run could cause loss of stability or even stack overflows. If you need to trigger a redraw within a lifecycle method, you should call `m.redraw` from within the callback of an asynchronous function such as `requestAnimationFrame`, `Promise.resolve` or `setTimeout`.
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ You DON'T need to call it if data is modified within the execution context of an
|
|||
|
||||
You DO need to call it in `setTimeout`/`setInterval`/`requestAnimationFrame` callbacks, or callbacks from 3rd party libraries.
|
||||
|
||||
Typically, `m.redraw` triggers an asynchronous redraws, but it may trigger synchronously if Mithril detects it's possible to improves performance by doing so. You should write code assuming that it always redraws asynchronously.
|
||||
|
||||
---
|
||||
|
||||
### Signature
|
||||
|
|
@ -32,4 +34,4 @@ When callbacks outside of Mithril run, you need to notify Mithril's rendering en
|
|||
|
||||
To trigger a redraw, call `m.redraw()`. Note that `m.redraw` only works if you used `m.mount` or `m.route`. If you rendered via `m.render`, you should use `m.render` to redraw.
|
||||
|
||||
You should not call m.redraw from a [lifecycle method](lifecycle-methods.md). Doing so will result in undefined behavior.
|
||||
You should not call m.redraw from a [lifecycle method](lifecycle-methods.md). Doing so will result in undefined behavior.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue