-
Notifications
You must be signed in to change notification settings - Fork 77
Event system #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can see how this may be useful, but I don't have any current use case for it. What performance implications would this have? Could it be configurable? Like, choose which events to broadcast (specified, all, or none)? |
I did some reading, and as of angular 1.2.16 there are no performance penalties for $rootScope.$broadcast. There is a 1:1 ratio of function invocations to number of listeners for the event. |
If there's 0 perf implications then I'd have no problem throwing it in. Though, like I said, I currently have no use case for this (finished my side-project where I was using angular-data). |
My only concern would be that the angular faq seems to recommend not to use broadcast/on for module specific events. But I am not sure if that is outdated, or if this could be defined as atomic events i guess. https://github.com/angular/angular.js/wiki/Best-Practices Is there still a 1:1 ratio if the .controller(function($scope) {
$scope.$on('DS.inject', function ($event, resourceName, injected) {
/// do something in response
});
}) |
Yes, 1:1 ratio.
The only events I would implement to start with would be /**
* @doc property
* @id DSProvider.properties:defaults.events
* @name DSProvider.properties:defaults.events
* @description
* Whether to broadcast, emit, or disable DS events on the `$rootScope`.
*
* Possible values are: `"broadcast"`, `"emit"`, `"none"`.
*
* `"broadcast"` events will be [broadcasted](https://code.angularjs.org/1.2.22/docs/api/ng/type/$rootScope.Scope#$broadcast) on the `$rootScope`.
*
* `"emit"` events will be [emitted](https://code.angularjs.org/1.2.22/docs/api/ng/type/$rootScope.Scope#$emit) on the `$rootScope`.
*
* `"none"` events will be will neither be broadcasted nor emitted.
*
* Current events are `"DS.inject"` and `"DS.eject"`.
*
* Overridable per resource.
*/
Defaults.prototype.events = 'broadcast'; |
There seems to be very little documentation about how the event system works, at least from what i found |
There isn't much to document other than what is already documented here, here, and here. Whenever |
What about adding an event system to angular-data, such that whenever angular-data does anything it broadcasts the result of the action on $rootScope. This would provide an avenue for asynchronously reacting to changes within the datastore. Example:
Somewhere else:
@kentcdodds @kenborge Thoughts?
The text was updated successfully, but these errors were encountered: