Comments (5)
I'll take a look into this today - do you have some example code that shows it because as far as I can tell, the tests suggest that it is working
from pusher-angular.
Example here: http://disparity.github.io/pusher-issue/
The tests do not cover this case, because only check for calling, but not that it is passed.
The user does not know anything about the interior decorators who wraps his listeners.
And when you try to unbind - passed the original listener, not a decorator and unbind not occur.
bind decorator: https://github.com/pusher/pusher-angular/blob/master/lib/pusher-angular.js#L168-L171
unbind listener: https://github.com/pusher/pusher-angular/blob/master/lib/pusher-angular.js#L181
from pusher-angular.
This should be fixed now 👍
You now get back a decorated version of the callback / handler that you pass to bind when you call bind and so you can then use that to unbind.
I've pushed out 0.1.8 as a new version.
Thanks for raising the issue
from pusher-angular.
IMHO not a good idea to return a decorated handler. The user does not need to know the internal implementation, with the decorator.
Then it is better to return a deregistration function for this listener, like a $scope.$on, which is useful for:
var unbindFunction = pusher.bind(event, listener);
$scope.$on('$destroy', unbindFunction));
or
var unbindFunction = pusher.bind(event, listener);
unbindFunction();
or
$scope.$on('$destroy', pusher.bind(event, listener)));
instead of current implementation:
var decoratedHandler = pusher.bind(event, listener);
$scope.$on('$destroy', function () {
pusher.unbind(event, decoratedHandler);
}));
from pusher-angular.
I can see the value of the different solutions you've described and they may well be more aligned with Angular conventions. I'm more than happy for you to make a pull request and I'll review it and likely merge it 👍
I only went with the solution I went with so that it was differing as little as possible from the pusher-js version.
from pusher-angular.
Related Issues (19)
- Small Readme fix HOT 1
- Example not working HOT 1
- binding to a event on a channel does not pass the context HOT 1
- Make $digest application configurable
- Question: Dynamically updating the auth headers HOT 4
- What happened to the pusher provider? HOT 1
- Suggestion: Move Examples directory, and related code, to a separate repository HOT 2
- Does it work with pusher-js 4.0 ? HOT 3
- receiving events multiple times HOT 1
- This works with Ionic v1?? HOT 1
- Update the library to support Angular 6+
- Binding to client- event throws 'Error: Presence channel required' HOT 2
- Retry auth request on error
- Test issue, please ignore
- Presence Channel Members HOT 5
- Problems with installing HOT 2
- Alternative CDN HOT 4
- No way to unbind to a Pusher Event HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pusher-angular.