Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope hostility in code #29

Closed
bshepherdson opened this issue May 1, 2014 · 3 comments
Closed

Scope hostility in code #29

bshepherdson opened this issue May 1, 2014 · 3 comments

Comments

@bshepherdson
Copy link
Contributor

From arthur...@google.com on October 22, 2013 15:00:27

Currently all models must be defined as global scope, e.g.

Model.create({
model_: 'Model',
name: 'MyModel',
...
});

If I want to have MyModel to be under a namespace, say cr.app.music.data.MyModel, that won't work. There are certain places in the FOAM code that is hostile to namespace scopes. For example, mm5Misc.js:140

defaultValueFn: function() { return GLOBAL[this.relatedModel].plural; }

The GLOBAL does have the relatedModel (cr.app.music.data.MyModel), but JavaScript won't allow one to access that thing as GLOBAL['cr.app.music.data.MyModel']. It accepts either cr.app.music.data.MyModel, or GLOBAL['cr']['app']['music']['data']['MyModel'].

Original issue: http://code.google.com/p/foam-framework/issues/detail?id=29

@bshepherdson
Copy link
Contributor Author

From k...@chromium.org on October 22, 2013 12:12:17

We will be getting rid of all globals. The plan is for all Models to explicitly declare their dependencies, which will then be satisfied by the inversion-of-control system, rather than letting objects access their dependencies explicitly from the global namespace.

@bshepherdson
Copy link
Contributor Author

From k...@chromium.org on October 22, 2013 12:12:40

Labels: -Type-Defect Type-Enhancement

@bshepherdson
Copy link
Contributor Author

This plan has been realized with requires and the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant