mobxjs / mobx-angularjs Goto Github PK
View Code? Open in Web Editor NEWMobX connector to AngularJS
License: MIT License
MobX connector to AngularJS
License: MIT License
It seems the ng-mobx.js
in dist is very huge since we use webpack to bundle both angular and mobx. However, package json describes both angular and mobx are peer dependencies. Hence the bundling part seems incorrect.
I don't know why using mobx instead of angular built-in digest cycle, is there any benefit?
I'm trying to load mobx-angularjs, but running into error above. Is that something that needs to be updated, or I'm loading it incorrectly?
When using latest version of mobx - currently 3.1.0, we are getting below error from yarn install log:
warning "[email protected]" has incorrect peer dependency "mobx@^2.6".
Does that mean ng-mobx is compatible only with mobx 2.x?
line 1 of mobx-autorun link is
var _a = $scope.$$watchers, $$watchers = _a === void 0 ? [] : _a;
this should be changed to $$watchers = typeof _a !== 'array' ? [] : _a;
Hello @adamkleingit. Now that we have mobx-angularjs
published to NPM, I think we can deprecate the ng-mobx
package.
I created a branch containing an updated README for you to publish.
https://github.com/mobxjs/mobx-angularjs/tree/deprecate-ng-mobx
If you could publish that to NPM and follow the deprecation steps, that would be great.
If you'd rather just add give me permissions on NPM, I can do it as well.
I'm looking at using this excellent looking library to retrofit a large AngularJS application where nearly everything is currently in the scope.
While I can follow what the the example is doing and why this directive is necessary here, I'm not sure what the best way to retrofit our code base is. For example, what should we do with existing code that uses "ng-click" or "ng-model" or anything that triggers a digest cycle? It seems to me that if we just referenced our mobx store through our scope and didn't change anything else, this directive wouldn't be necessary.
So...is the recommendation to use "onclick" instead of "ng-click" when triggering a mobx action, for example?
Thanks!
This will run all the watchers inside autorun and track all the dependencies, without using internal angular variables
mobx.autorunAsync('$rootScope#$digst', () => {
$rootScope.$digest();
}, 2);
Please let me know if I missed anything
https://github.com/500tech/ng-mobx/blob/master/lib/ng-mobx.js#L20
This happens if you use mobx-autorun
and ng-if
on the same element.
<div ng-if="!$ctrl.sessionStore.isLoggedIn()" mobx-autorun>
// login
</div>
<div ng-if="$ctrl.sessionStore.isLoggedIn()" mobx-autorun>
// logout
</div>
Moving mobx-autorun to a wrapper fixes the issue, but this is not always ideal.
<div mobx-autorun>
<div ng-if="!$ctrl.sessionStore.isLoggedIn()">
// login
</div>
<div ng-if="$ctrl.sessionStore.isLoggedIn()">
// logout
</div>
</div>
If I remove this line import angular from 'angular';
the error goes away.
Angular is not actually needed in that file so that line can be safely removed.
Hi,
I am currently getting the following error:
[$rootScope:inprog] $apply already in progress
http://errors.angularjs.org/1.5.11/$rootScope/inprog?p0=%24apply
When i apply the directive to an ng-repeat like:
<tr mobx-autorun ng-repeat="employee in $ctrl.employees">
<td>{{employee.id}}</td>
<td>{{employee.firstName}}</td>
<td>{{employee.lastName}}</td>
<td>{{employee.fullName}}</td>
</tr>
Should the following code:
!$scope.$$phase && $scope.$digest()
not be:
var phase = this.$root.$$phase;
if(phase == '$apply' || phase == '$digest') {
see: https://coderwall.com/p/ngisma/safe-apply-in-angular-js
Where should I place the 'mobx-autorun' for nested components?
Hello @adamkleingit.
This library has proven useful to me in the past few days. I hope to get my company to use it soon in order to ease a transition from AngularJS to React. I appreciate the time you put into it.
I had a few issues and noticed that @kuitos had forked and fixed most of them. It seems that you may not have had the time or desire to keep up with the maintenance of this project to merge them back in, #5, which is totally understandable when you are busy maintaining something like mobxjs/mobx-angular. I, on the other hand, do not have any open source projects to maintain and would love to help out.
If you are up for it, I propose that we make a few changes:
We could possibly move the repo under the mobxjs organization as mobxjs/mobx-angularjs
, cc @mweststrate.
Deprecate ng-mobx on npm, and align it with the same naming convention as mobx-angular, publishing under mobx-angularjs
, if that is okay with @kuitos.
Align the codebase with the conventions of mobx-angular
and incorporate changes made by @kuitos. I have done this here and will gladly submit a PR.
Cheers!
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.