https://github.com/cundd/irlib
General purpose JavaScript framework
https://github.com/cundd/irlib
Last synced: about 1 year ago
JSON representation
General purpose JavaScript framework
- Host: GitHub
- URL: https://github.com/cundd/irlib
- Owner: cundd
- Created: 2015-08-17T09:02:57.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-01-31T11:13:46.000Z (over 9 years ago)
- Last Synced: 2025-05-15T12:11:32.010Z (about 1 year ago)
- Language: JavaScript
- Size: 292 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
irlib
=====
> A simple JavaScript library
Installation
------------
With `npm`
```bash
npm install irlib --save-dev
```
or `Composer`
```bash
composer require cundd/irlib
```
Service Locator
---------------
### Create the Service Locator
```javascript
var sl = new IrLib.ServiceLocator();
```
### Retrieve an instance
```javascript
var controller = sl.get('registeredKey');
```
### Import a ES6 module and register it
```javascript
import App from './App.js';
sl.register('app', App);
```
### Register a factory method
```javascript
sl.register(
'appView',
function () {
return new Instance();
}
)
```
### Register a controller with dependencies (inline)
```javascript
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
```javascript
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();
}
}
}
})
});
```