cundd / irlib
通用JavaScript框架
0.1.4
2016-08-07 10:42 UTC
This package is auto-updated.
Last update: 2024-09-10 22:34:14 UTC
README
一个简单的JavaScript库
安装
使用 npm
npm install irlib --save-dev
或 Composer
composer require cundd/irlib
服务定位器
创建服务定位器
var sl = new IrLib.ServiceLocator();
检索一个实例
var controller = sl.get('registeredKey');
导入ES6模块并注册它
import App from './App.js'; sl.register('app', App);
注册一个工厂方法
sl.register( 'appView', function () { return new Instance(); } )
注册一个带依赖项的控制台(内联)
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(); } } } }) });
设置依赖项的属性名称
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(); } } } }) });