Giter VIP home page Giter VIP logo

monkeyinject's Introduction

MonkeyInject

A dependency injection framework for ConnectIQ Applications

Bind Classes to interfaces, declare your dependencies, and let MonkeyInject handle building.

Usage

Modules

Modules are where you bind your interfaces to concrete classes. Create your own Module class and extend the MonkeyInject.Module that is included in the library.

Modules bind interfaces, described by symbols to ClassDefs.

class ConcreteWriteable {
  function write(){
    // Do some work.
  }
}

class MyModule extends MonkeyInject.Module {
  function initialize() {
    Module.initialize();

    bind(:Writeable)          // Bind the Writeable Interface
      .to(ConcreteWriteable); // To the ConcreteWriteable class
  }
}

Bindings support different scopes, to determine when a new instance of the concreate class will be created. Read about Bindings in the Wiki (todo).

Kernel

The entry point for the library is the Kernel object. Instantiate the kernel, load modules, and call build(). The framework will then handle building all of the appropriate dependencies and will return a fully initialized implementation of the interface requested.

class MyApp extends Application.App {
  private var _writeable;
  private var _kernel;

  function initialize() {
    _kernel = new MonkeyInject.Kernel();
    _kernel.load(new MyModule());

    _writeable = _kernel.build(:Writeable);
  }
}

monkeyinject's People

Contributors

gcaufield avatar

Stargazers

 avatar

Watchers

 avatar  avatar

monkeyinject's Issues

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.