mgechev / angular-immutable Goto Github PK
View Code? Open in Web Editor NEWSimple directive, which allows binding to Immutable.js collections.
Simple directive, which allows binding to Immutable.js collections.
bad sourceURL
//# sourceURL=/Users/soocheng/Documents/angular-immutable/lib/immutable.js
Hello.
I am following your blog post http://blog.mgechev.com/2015/03/02/immutability-in-angularjs-immutablejs/ and using the latest immutable.js
- v3.7.6
.
Running the first example that uses angular-immutable
brings the following warning:
iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version. Error
at List.Object.defineProperty.get (http://localhost:8080/node_modules/immutable/dist/immutable.js:4650:21)
at isArrayLike (http://localhost:8080/node_modules/angular/angular.js:282:46)
at $watchCollectionInterceptor (http://localhost:8080/node_modules/angular/angular.js:16192:22)
at Object.regularInterceptedExpression (http://localhost:8080/node_modules/angular/angular.js:14949:16)
at Scope.$digest (http://localhost:8080/node_modules/angular/angular.js:16390:40)
at Scope.$apply (http://localhost:8080/node_modules/angular/angular.js:16662:24)
at bootstrapApply (http://localhost:8080/node_modules/angular/angular.js:1679:15)
at Object.invoke (http://localhost:8080/node_modules/angular/angular.js:4657:17)
at doBootstrap (http://localhost:8080/node_modules/angular/angular.js:1677:14)
at Object.bootstrap (http://localhost:8080/node_modules/angular/angular.js:1697:12)
Although it's a warning, I wanted to point this out.
Thank you.
Hi,
There seems to be no support for controllerAs syntax. It there any planned support for controllerAs syntax ?
I have been experimenting with your directive and these 2 functions, but with any solid result yet.
function getPropertyByPath(obj, path) {
var i, j, parent, ref;
path = path.split('.');
parent = obj;
if (path.length > 1) {
for (i = j = 0, ref = path.length - 2; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
parent = parent[path[i]];
}
}
return parent != null ? parent[path[path.length - 1]] : void 0;
}
function setPropertyByPath(obj, path, value) {
var i, j, name, parent, ref;
path = path.split('.');
parent = obj;
if (path.length > 1) {
for (i = j = 0, ref = path.length - 2; 0 <= ref ? j <= ref : j >= ref; i = 0 <= ref ? ++j : --j) {
parent = (parent[name = path[i]] || (parent[name] = {}));
}
}
return parent[path[path.length - 1]] = value;
}
bower install angular-immutable is returning version of 0.0.1
Do you plan a release on npm ?
Hi Minko
I am following up from my comments on your excellent blog series about using immutables with angular.
Given the current implementation of immutable.js and angular, I don't see how any performance benefit can be realized from the immutable filter in this repo. I understand there is performance benefit when using immutables as the expr in a $watch(expr, listener, false), due to the fast reference checking.
But the point of this filter is to return an equivalent native datastrucutre from the immutable using the toJS() method. The object returned is always a new object. Because of this, if we were to use this filter in an expr to $watch(expr, listener, false), we would get many false positives and redundant invocations of listener (as you know the $digest is constantly running and evaluating expr even when expr isn't changing).
If used with $watchCollection, such as in <li ng-repeat="item in list | immutable">
, we get no performance benefit as watchCollection doesn't compare references, but always looks for changes in the collection regardless.
In fact, using this filter can only degrade performance, because of the garbage collection overhead you describe in your blog.
Please correct me if I'm understanding this wrong, and thanks for the research.
Matt
The error is occurring where we specify ng-controller="name as alias"
<div ng-controller="ctrl as vm">
{{vm.data}}
<ul>
<li immutable="vm.list" ng-repeat="items in vm.list" ng-bind="items">
{{items}}
</li>
</ul>
</ul>
</div>
Sample http://plnkr.co/edit/Fo1koZvxemrQYEsns9w0
Update 1: You will need to loop through string provided for the attribute to reach the correct reference.
This library is super useful. Thank you!
It would be great to have compatibility with controllerAs so that it isn't necessary to use $scope. Is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.