Comments (10)
Instead of just passing static configs to init(), I'd like instead to pass a "model context" (or "model proxy"). The configs (app or mojit) can be gotten from this proxy. This would be a larger change though -- a bit of an architectural change.
from mojito.
This pull request was accepted and applied. It's in 0.3.8 now. Thank you!
from mojito.
Just wanted to ask if there is any documentation for this? I am trying to access config in defaults.json in model.
from mojito.
I didn't find any documentation addressing this specifically. I do notice that if a model as an init()
method it is passed a single parameter which contains the instance config. (The instance config is a merge of the spec (as found in application.json) and the defaults.json.)
(Not sure why this issue got closed as an accepted pull request... 😕 )
from mojito.
I tried passing ac.config to init() But for some reason it's coming as null. Though there is no config in the spec for my mojit, I was expecting it to contain the ones from defaults.json. - which brings another question, is defaults.json mojit level or app level ? If it's mojit level what is the standard way to define app level configurations and how to use it?
from mojito.
The init()
method is called automatically by the mojito as the model is created.
One approach is to pass the config you want to each method of your model as needed, something like model.foo(config, ...)
. You can get the config similar to what you were doing with ac.config. However, ac.config is an API object (and it only exists if your controller depends on the mojito-config-addon
). You'll need to pass the results of ac.config.get()
or ac.config.getAppConfig()
.
from mojito.
Ok. this is what I had to do to get this work. call model.init(ac.config) and define setting in "config" of the mojit in application.json.
Which is all fine but how do I have a config defined once for the entire application? I thought putting a defaults.json in app level will take care of it, but it didn't.
from mojito.
Here's the API documentation for the ac.config addon:
http://developer.yahoo.com/cocktails/mojito/api/classes/Config.common.html
from mojito.
Generally if you want to define a config for the whole application you want to put it into application.json
. Then you can use ac.config.getAppConfig()
to get those values out.
from mojito.
Thank you very much. Got it working.
from mojito.
Related Issues (20)
- Request for mojito-cli creating templates using Promises HOT 10
- ac.partial.render() throws error for handlebar custom helper HOT 14
- Featurerequest: reviver-method for params.getFromBody-bodyparsing json stringified requests HOT 1
- request for MojitProxy.refreshView() not to reload css-assets HOT 13
- mojito test crashes when require() is used HOT 2
- escape comboBase will cause some combo handler stop working HOT 3
- On middleware registration, pass in the `mojito` object HOT 13
- custom yui module invisible in test HOT 1
- [docs] mojitProxy.invoke() HOT 1
- For some reason I have obtained this issue when i run mojito on windows HOT 2
- Exception on mp.destroyChildren() when used again after refreshView()
- mojito crash when page is reloaded and a mojit invoke() is in progress HOT 1
- Static context not reflected in request's context HOT 4
- ac.error() sends an empty response to binder HOT 1
- Routes exposed to the client HOT 2
- after ac.cookie.set() ac.cookie.get() returns "undefined" - bug? HOT 3
- Error : During Dynamic mojit creation HOT 1
- Load custom template view in ac.composite.execute HOT 3
- `mojito start` not working HOT 4
- Switch "express-state" internal module require()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mojito.