rolaveric / angular-falcor Goto Github PK
View Code? Open in Web Editor NEWSimple example of using FalcorJS with AngularJS v1.x
License: MIT License
Simple example of using FalcorJS with AngularJS v1.x
License: MIT License
Change the example to use inputs with ng-model that then get/set from the falcor model.
One option may be to create a model.createGetterSetter(path)
method which generates functions that can get or set a path value, depending on whether a parameter is passed or not.
These functions could then be used with ng-model-options="{ getterSetter: true }"
: https://docs.angularjs.org/api/ng/directive/ngModel#binding-to-a-getter-setter
This will require the controller to setup those getterSetter functions though - no getting around that.
Another option may be to create a directive which uses the ngModelController: https://docs.angularjs.org/api/ng/type/ngModel.NgModelController
Create some unit tests (tsk tsk), especially ones that show how to mock the falcor.Model data since we don't have $httpBackend to rely on.
One option would be to rely on models being wrapped up as angular services, so they're injectable singletons. Then unit testing is a simple matter of swapping out for a mock version.
A standard factory for mock models would be useful. We can't just use a falcor.Model with preset cache for two reasons:
model.call()
won't work without a router.The filters from #2 work, but have ugly syntax.
A better option may be to decorate the Falcor.Model
object to work better with AngularJS 1.
getNgValue(Path)
: Returns value from getCache()
. If undefined, makes getValue()
call with safeApply($rootScope)
.
To take this example up to 11, going to need something equivalent to the 'async' pipe from the Angular 2 examples.
The common solution is to use a stateful filter:
http://stackoverflow.com/questions/19046641/asynchronously-initialize-angularjs-filter
Right now the only purpose rx-angular
serves is to add the safeApply()
method to Rx.Observable.prototype
.
However there's two problems with this:
$scope.$$phase
check that safeApply()
uses is considered bad practice, compared to using $timeout()
or $scope.$evalSync()
: http://www.bennadel.com/blog/2605-scope-evalasync-vs-timeout-in-angularjs.htmRx.Observable.prototype
will no longer be viable: Netflix/falcor#465Approaching a point where the code may be reusable in other projects.
Should wrap the reusable code into library and move the example code into an 'example/' folder.
Should apply some performance analysis on the AngularJS falcor
service.
getViewValue()
and viewGetterSetter()
methods, looking for memory leaks and optimisations. eg. I suspect the inProgress
cache is redundant.getViewValue()
and viewGetterSetter()
run at scale. eg. 5 vs 50 vs 500. Benchpress may be a good tool to use.You should probably use call. That will require you to create a router though (no offline call). You can start with the router in the Falcor router demo. http://github.com/netflix/falcor-router-demo
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.