@cerebral/angular
Advanced tools
+17
-4
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var cerebral_1 = require("cerebral"); | ||
| var assign = function (a, b) { | ||
| return Object.keys(b).reduce(function (current, key) { | ||
| current[key] = b[key]; | ||
| return current; | ||
| }, a); | ||
| }; | ||
| function connect(dependencies) { | ||
@@ -9,6 +15,8 @@ return function (target) { | ||
| var _this = this; | ||
| this.props = Object.assign({}, this); | ||
| this.props = assign({}, this); | ||
| this.onUpdate = function (stateChanges, force) { | ||
| _this.view.updateFromState(stateChanges, _this.props, force); | ||
| Object.assign(_this, _this.view.getProps(_this.props, false)); | ||
| _this.view.render(_this.props, function (componentProps) { | ||
| assign(_this, componentProps); | ||
| }, false); | ||
| _this._cdr.detectChanges(); | ||
@@ -31,3 +39,5 @@ }; | ||
| if (hasUpdate) { | ||
| Object.assign(_this.ctrl, _this.view.getProps(nextProps, false)); | ||
| _this.view.render(nextProps, function (componentProps) { | ||
| assign(_this, componentProps); | ||
| }, false); | ||
| _this._cdr.detectChanges(); | ||
@@ -43,6 +53,9 @@ } | ||
| target.prototype.ngAfterViewInit = function () { | ||
| var _this = this; | ||
| if (targetNgAfterViewInit) { | ||
| targetNgAfterViewInit.apply(target); | ||
| } | ||
| Object.assign(this, this.view.getProps(this.props, false)); | ||
| this.view.render(this.props, function (componentProps) { | ||
| assign(_this, componentProps); | ||
| }, false); | ||
| this._cdr.detectChanges(); | ||
@@ -49,0 +62,0 @@ }; |
+3
-20
| { | ||
| "name": "@cerebral/angular", | ||
| "version": "4.0.0-1521140905511", | ||
| "version": "4.0.0-1525724201307", | ||
| "description": "Angular view for Cerebral", | ||
@@ -17,23 +17,6 @@ "main": "index.js", | ||
| "dependencies": { | ||
| "cerebral": "^5.0.0-1521140905511" | ||
| "cerebral": "^5.0.0-1525724201307" | ||
| }, | ||
| "devDependencies": { | ||
| "@angular/common": "^4.4.0-RC.0", | ||
| "@angular/compiler": "^4.4.0-RC.0", | ||
| "@angular/core": "^4.3.6", | ||
| "@angular/platform-browser": "^4.4.0-RC.0", | ||
| "@angular/platform-browser-dynamic": "^4.3.6", | ||
| "@types/express": "^4.0.37", | ||
| "@types/mocha": "^2.2.47", | ||
| "@types/node": "^9.4.0", | ||
| "assert": "^1.4.1", | ||
| "babel-cli": "^6.24.1", | ||
| "babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
| "core-js": "^2.5.0", | ||
| "express": "^4.15.4", | ||
| "ts-node": "^3.3.0", | ||
| "zone.js": "^0.8.17" | ||
| }, | ||
| "scripts": { | ||
| "test": "TS_NODE_IGNORE=false mocha --require test/setup.ts --compilers ts:ts-node/register,tsx:ts-node/register --require ts-node/register test/**/*.ts*", | ||
| "test": "TS_NODE_IGNORE=false mocha --require test/setup.ts --require ts-node/register test/**/*.ts", | ||
| "build": "tsc -p ./src", | ||
@@ -40,0 +23,0 @@ "coverage": "nyc --reporter=lcov --reporter=json npm run test", |
+12
-2
@@ -10,2 +10,3 @@ # @cerebral/angular | ||
| ## CerebralService | ||
| The Cerebral service exposes the Cerebral controller to your application. | ||
@@ -52,8 +53,17 @@ | ||
| ## connect decorator | ||
| The connect decorator connects state and signals to your components. | ||
| ```ts | ||
| import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core' | ||
| import { | ||
| Component, | ||
| ChangeDetectionStrategy, | ||
| ChangeDetectorRef | ||
| } from '@angular/core' | ||
| import { signal, state } from 'cerebral/tags' | ||
| import { connect, ControllerService, CerebralComponent } from '@cerebral/angular' | ||
| import { | ||
| connect, | ||
| ControllerService, | ||
| CerebralComponent | ||
| } from '@cerebral/angular' | ||
@@ -60,0 +70,0 @@ @Component({ |
+2
-1
@@ -8,4 +8,5 @@ { | ||
| "strict": true, | ||
| "lib": [ "es2015" , "es2017", "dom"] | ||
| "strictPropertyInitialization": false, | ||
| "lib": ["es2015", "es2017", "dom"] | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
0
-100%135
11.57%91
12.35%8590
-2.05%12
-7.69%