Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd support for promise resolution in createViewModel function of components #77
Comments
|
Related: #64 |
|
I get it. Will look into it, for sure. I feel like reworking the loader in general, too. Just to ensure I’m on the right page, can you put together a codepen or jsfiddle that shows how a sample case and comments the expected behaviour? |
|
@brianmhunt - I think this should be as simple a codepen I can get that gives an example of what and how it should be supported. Welcome to other's ideas/inputs as well codepen. |
I find that it would be really helpful in a few situations if I could inject a promise (which maybe doing ajax and/or indexeddb work) just before my component is displayed. This is somewhat supported by the AMD/require syntax, but does not seem to be simple/straightforward. It would be helpful if we could return a promise from createViewModel, that is awaited before the component is created and instantiated.
What I see the team always doing instead is creating some "loaded" Observable that is set after the component initialization finishes. This creates extra paints in some cases that just seem unnecessary - especially when working with indexeddb, or just a cached ajax get. The 3-5 ms wait triggering multiple paints, plus when tracking dirty, the issue of dealing with new viewmodel state change (after construction) seems like a lot of effort could be simplified if createViewModel supported returning a promise that returns a viewmodel. That would let us deal with many of these issues in a clean and natural way right at component instantiation. Since the component loader is asyncronous anyway, seems like this shouldn't be too hard to add.