choo
choo copied to clipboard
Asynchronous render
Fixes #645
This code requires that any browser or node instance that doesn't support async be compiled using babel and the polyfill being included.
Being that we still have support enabled for IE 11 and Safari (browser which represent more than 1% of usage), this adds a lot of weight to choo. (babel-poylfill is around 85k depending on compression which is MUCH larger than choo)
I just realised that, I'm removing async/await now
Also, check out my comments in #645 -- there are other ways to do this without needing to change how choo works
I forgot to mention but this change is also backward compatible, normal sync rendering will still work
Promise still needs to be shimmed for IE 11 (so we'd likely also need to include a promises implementation in core).
Does it have to be included in core? It could be up to the developer to decide if she wants it or not and which shim to use. Otherwise we could use es6-promise in core, it takes 2.4 KB gziped
I think this whole PR could fit for a store. Since the the .use function expose the app instance, you can change whatever you want there, maybe is a good idea to have it as astore and make some tests and bench on top of it.
@YerkoPalma that's actually a good idea. I could definitely do it but, there is a recent change to delegate store initialisation (https://github.com/choojs/choo/pull/638), it makes it harder since the patching would only be applied after calling start or toString and I also need to patch those 2
@toddself I updated the PR so that the a Promise shim is only required if the developer wants to go with async rendering. If there are no promises being passed to html, everything works just like before.
I really like this implementation, as it brings the best of both worlds and it's not a breaking change. I would add some more tests with mixed values (promises, literals) as well.
Any update on this? :)
Anything a noob contributor (me lol) could help out with?