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

Declare Context wiring configs in external files #35

Closed
geekdave opened this issue Sep 5, 2013 · 1 comment
Closed

Declare Context wiring configs in external files #35

geekdave opened this issue Sep 5, 2013 · 1 comment

Comments

@geekdave
Copy link
Contributor

geekdave commented Sep 5, 2013

Would be nice to externalize the wiring like so:

using a single wiringConfig file

src/user/UserContext.js

define([
  "geppetto",
  "src/user/wiringConfig.js"
], function(
  Geppetto,
  wiringConfig
) {
  return Geppetto.Context.extend({
    wiring: wiringConfig
  });
});

src/user/wiringConfig.js

define([
  "src/users/commands/FooCommand.js",
  "src/users/commands/BarCommand.js",
  "src/users/foo.js",
  "src/users/qux.js"
], function( 
  FooCommand,
  BarCommand,
  Foo,
  Qux
) {
  return {
    commands: {
        "appEventFoo":          FooCommand,
        "appEventFooBarBaz":   FooCommand
    },
    singletons: {
        foo: Foo
    },
    classes :{
        bar: Bar
    },
    values : {
        someValue: 10
    },
    views: {
        qux : Qux
    }
  }
});

using multiple config files

src/user/UserContext.js

define([
  "geppetto",
  "src/user/wiring/commands.js",
  "src/user/wiring/singletons.js",
  "src/user/wiring/classes.js",
  "src/user/wiring/values.js",
  "src/user/wiring/views.js"
], function(
  Geppetto,
  commandsConfig,
  singletonsConfig,
  classesConfig,
  valuesConfig,
  viewsConfig
) {
  return Geppetto.Context.extend({
    wiring: {
        commands: commandsConfig,
        singletons: singletonsConfig,
        classes: classesConfig,
        values: valuesConfig,
        views: viewsConfig
    }
  });
});

src/user/wiring/commands.js

define([
  "src/users/commands/FooCommand.js",
  "src/users/commands/BarCommand.js"
], function(
  FooCommand,
  BarCommand
) {
  return {
        "appEventFoo":          FooCommand,
        "appEventFooBarBaz":   BarCommand
  }
});

src/user/wiring/singletons.js

define([
  "src/users/foo.js"
], function(
  Foo
) {
  return {
        foo: Foo
  }
});
@geekdave
Copy link
Contributor Author

geekdave commented Jan 6, 2014

I just tested, and this is already possible using the above examples. It's just plain ol' RequireJS functionality, with no special Geppetto features necessary. Closing.

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

No branches or pull requests

1 participant