-
-
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
Have m.redraw()
schedule a second successive redraw when called during an existing redraw
#1728
Comments
Apparently, the current behavior has been tripping up people on Gitter. |
Problem ClarificationFollowing should redraw when calling m.redraw() oncreate = (vnode) ->
#This replaces the 'editor' div with an Ace editor
ace.edit('#editor')
# This redraw doesn't seem to have any effect
m.redraw()
view = (vnode) ->
m "#editor" Current workaround for this is: function asap(){
return new Promise(function(resolve){
setTimeout(resolve)
})
}
// later
function oncreate(){
asap().then(m.redraw)
} |
Small typo, the
Although I'm not sure how the |
I think without asap(), mithril is still inside one redraw, not firing wished-for-redraw. With asap(), it should(?) fire after current redraw is finished. Why with oncreate hook, render not complete yet is the issue. |
@salamynder My proposal would fix your issue with zero change from your part, BTW (although IMHO it should actually schedule something instead). The issue you're running into is that Mithril throttles its calls, but it doesn't actually schedule anything to be run after the throttle timer ends, thus your issue. |
@salamynder why do you want to redraw at that point? The initialization/redering of the editor should be independent of Mithril's redraws... Are you passing extra information to the editor on redraw? Couldn't it be passed after the If you don't mind using either the micro-task (native Promises) or the macro-task scheduler (Mithril Promise polyfill), asap becomes function asap(){ return Promise.resolve() } @cyberco @isiahmeadows I've suggested something similar in #1592 for |
@cyberco @pygy @isiahmeadows Bottom-line (for me right now, just trying envisage switch to mithril-new): documentation?However, I still don't get why there is a difference between the (1) oncreate-component-function and the (2) oncreate-m-helper-attribute, also with regard to the fact that they share the same name. This should maybe be better documented on the website, section "Resources / Integrating Third Party Stuff"? (In the vein of: http://mithril.js.org/archive/v0.2.5/integration.html ?) |
@salamynder You can define hooks, both on the component and in attributes. The latter are mostly useful for defining hooks on non-component vnodes (e.g. set the focus on a given form field in You didn't address my previous questions, I still don't understand what you're trying to achieve and what doesn't work... Could you provide a JSBin/JSFiddle/CodePen/...? is the Ace Editor stuff a red herring and you want to redraw for other reasons? |
@pygy The goal for @cyberco (OP) was, I think, to render the ace editor using |
@salamynder my bad, I missed the original discussion on Gitter and tought you were the OP... Thanks for providing context. |
@cyberco based on our conversation on Gitter, can you confirm that ACE editor initialises fine without calling an extra redraw, and that the original requirement for that redraw is redundant since ACE editor is designed to operate independently of Mithril? |
@pygy @cyberco @barneycarroll |
@pygy To clarify, I'm thinking of scheduling a redraw after the throttle ends. |
@isiahmeadows IIRC that's +/- what happens in #1592, with a caveat when there are multiple mount points.
|
@pygy So should that be considered another reason to make (Or at least async when called during an existing render) |
Closing in favor of #1847. |
Edit: Moved my previous edit lower to clarify what particularly I'm talking about.
This would entail a boolean
rendering
global and booleanagain
global within the renderer to handle this scenario. It's already come up on Gitter, and there are legitimate use cases for this.Edit: This specific proposal coded here is junk. It should really be asynchronously scheduling something here.
Here's how it'd work, in terms of the existing API:
The text was updated successfully, but these errors were encountered: