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
refresh the ui from outside dom event handlers? #3
Conversation
onload would be nicer in the respect that you don't need a reference to the return value from plastiq.attach, which will be awkward to pass around. Shall I have a go with onload instead? |
Oops, did I just ask for a component model? |
Yeah, I thought this would be a good idea. Onload is interesting too but sounds a little contrived since it's only going to be called once, but it does allow components deep inside the view to participate in a kind of "initial loading" behaviour without having to be aware of The other interesting thing about this particular example is that you can check for the existence of I'm thinking that |
Oh! I've been thinking about other things like routing, and how routing would have to |
The other thing I was thinking about was being able to subscribe to |
|
And the other other thing I was thinking about was firebase, and couchdb, and other model synchronisers. They would need to |
like it! |
Had a play with the "onattach" idea (n.b. this test doesn't pass yet): virtual-dom supports "hook" attributes, but hooks will fire on every render or patch, which is not what we want. In order to fire a once-off event, something needs to know whether it's the first render, or a patch. Of course, plastiq knows this, but it would need to descend the tree and remove the onattach hooks before a patch, which doesn't seem right. Another option is that the render function takes an I'll keep digging... |
I found a way to implement onattach but for the reasons you mentioned above (couchdb and firebase) we might still need this one. |
@adiel mentioned another example of where he might need this, or something like it... If you have an existing HTML page, and you want to attach plastiq to two different elements in that DOM, with a shared model. You are not ready or willing to let plastiq render the entire DOM -- so you'd need a way of refreshing both elements when the model changes. |
Yeah I was thinking about this too. Would solve the original React use-case on FaceBook: message count on top, messages at bottom. API: var model = {}
var page = plastiq.page();
page.attach(document.querySelector('#one'), renderOne, model);
page.attach(document.querySelector('#two'), renderTwo, model); |
Not needed now... |
Not sure this is a good idea, perhaps I am missing a trick. I was trying to render a loading screen until an async operation completes:
I also tried attaching an onload handler in render, which seems more consistent but didn't work and I'm not sure that's a good idea either. Am I missing an alternative?