cundd/irlib

General purpose JavaScript framework

Maintainers

Details

github.com/cundd/irlib

Source

Issues

Installs: 17

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 1

Language:JavaScript

0.1.4 2016-08-07 10:42 UTC

This package is auto-updated.

Last update: 2024-04-10 21:43:23 UTC


README

A simple JavaScript library

Installation

With npm

npm install irlib --save-dev

or Composer

composer require cundd/irlib

Service Locator

Create the Service Locator

var sl = new IrLib.ServiceLocator();

Retrieve an instance

var controller = sl.get('registeredKey');

Import a ES6 module and register it

import App from './App.js';
sl.register('app', App);

Register a factory method

sl.register(
        'appView',
        function () {
        		return new Instance();
        }
)    

Register a controller with dependencies (inline)

sl.registerMultiple({
	appController: IrLib.Controller.extend({
		needs: ['appView'],
		events: {
			click: function (e) {
				if (e.target.id === 'save') {
					this.appView.assignVariable('saved', this.appView.variables.saved + 1);
					this.appView.reload();
				}
			}
		}
	})
});  

Set the property name for the dependency

sl.registerMultiple({
	appController: IrLib.Controller.extend({
		needs: ['appView:view'],
		events: {
			click: function (e) {
				if (e.target.id === 'save') {
					this.view.assignVariable('saved', this.view.variables.saved + 1);
					this.view.reload();
				}
			}
		}
	})
});