Giter VIP home page Giter VIP logo

Comments (10)

drewfish avatar drewfish commented on June 2, 2024

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.

isao avatar isao commented on June 2, 2024

This pull request was accepted and applied. It's in 0.3.8 now. Thank you!

from mojito.

jithine avatar jithine commented on June 2, 2024

Just wanted to ask if there is any documentation for this? I am trying to access config in defaults.json in model.

from mojito.

drewfish avatar drewfish commented on June 2, 2024

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.

jithine avatar jithine commented on June 2, 2024

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.

drewfish avatar drewfish commented on June 2, 2024

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.

jithine avatar jithine commented on June 2, 2024

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.

drewfish avatar drewfish commented on June 2, 2024

Here's the API documentation for the ac.config addon:
http://developer.yahoo.com/cocktails/mojito/api/classes/Config.common.html

from mojito.

drewfish avatar drewfish commented on June 2, 2024

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.

jithine avatar jithine commented on June 2, 2024

Thank you very much. Got it working.

from mojito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.