Every Component should still have the app property in 2.7. There aren't any new features specifically for sharing state in 2.7. You could use a module exporting an regular object or an enyo Component as well.
I have two modules I want in available anywhere in my app. One is the current logged in user and the other is a task timer. I can't grok how to add those to the Application - should I require() them in the App.js generated by my onyx-webos-app template (basically the same as onyx-app template)?
Assuming that myUser and myTimer were enyo kinds, that should work. If they are singletons or something else (e.g. POJO), you could require() them directly wherever you needed them. For application state, I would probably lean to attaching them to the app in some way. For utilities, I'd prefer directly requiring them where they are used.
Comments
app
property in 2.7. There aren't any new features specifically for sharing state in 2.7. You could use a module exporting an regular object or an enyo Component as well.Neither require.js nor Node guarantee a singleton, IIRC.
And then is the access from any component like this?
this.app.$.myUser
-Thanks in advance!
require()
them directly wherever you needed them. For application state, I would probably lean to attaching them to the app in some way. For utilities, I'd prefer directly requiring them where they are used.HTH!
enyo/Application
.