Skip to content

Proposed API #32

@creynders

Description

@creynders

API proposition for Backbone.Geppetto:

Based on #22, #24 and #28

  1. createChildResolver() <- Injector#createChildInjector
  2. getObject(key) unchanged
  3. wireValue(key, value) <- Injector#mapValue
  4. hasWiring(key) <- Injector#hasMapping
  5. wireClass(key, clazz) <- Injector#mapClass
  6. wireView(key, clazz) <- Injector#mapView
  7. wireSingleton(key, clazz) <- Injector#mapSingleton
  8. instantiate(key) unchanged
  9. resolve(instance) <- Injector#injectInto
  10. release(key) <- Injector#unmap
  11. releaseAll(key) <- Injector#unmapAll
  12. bindContext(options) unchanged
  13. on(event, callback, [scope]) <- Context#listen (Backbone.Events)
  14. once(event, callback, [scope]) new (Backbone.Events)
  15. off([event], [callback], [scope]) new (Backbone.Events)
  16. listenTo(other, event, callback) <- Context#listen (Backbone.Events)
  17. listenToOnce(other, event, callback) new (Backbone.Events)
  18. stopListening([other], [event], [callback]) new (Backbone.Events)
  19. trigger(event, [...args]) <- Context#dispatch (Backbone.Events)
  20. triggerOnParent(event, [...args]) <- Context#dispatchToParent
  21. triggerGlobally(event, [...args]) <- Context#dispatchGlobally
  22. wireCommand(event, commandClass) <- Context#mapCommand
  23. wireCommands(wirings) <- Context#mapCommands
  24. destroy() <- Context#unmapAll

And as an optional parameter to Context#initialize:

wires:{ //or maybe 'wirings' ?
    commands: {
        "appEventFoo":          FooCommand,
        "appEventFooBarBaz":    [
            FooCommand,
            BarCommand,
            BazCommand
        ]
    },
    singletons: {
        foo: Foo
    },
    classes :{
        bar: Bar
    },
    values : {
        someValue: 10
    },
    views: {
        qux : Qux
    }
}

So, what do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions