-
-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Is there a reason why Feathers sends all events to all of its clients by default? #421
Comments
This is indeed a very good question. We have some updates for the filtering mechanism lined up (see #388 (comment)) but I like what you are suggesting and unlike #388 I think we might be able to get this into a non-breaking release. With a Do you think it should be on a per event basis though? I'd probably make it per-service because it would be less to keep track of and in a filter you can just check |
@daffl I'm not sure about that. It's always a tradeoff. In my opinion we can go even further and make those subscriptions more granular. In real life in most cases we want to get updates related to a particular document. For example, when the user opens a chat room, he wants to get the updates made in that particular room. So in addition to the It would really make life easier for developers. It's a bit more complicated to implement, but the concept is the same. And all the three levels of granularity may be optional. |
Hi there mates! I just created something about it on my app, I created my own view controller side with angular 1.x and angular routes, when I get the event I only update user_id screen, or if you are admin or it is an dashboard route, you know what I mean? |
This can now be done pretty nicely with channels:
On the client: const io = require('socket.io-client');
const feathers = require('@feathersjs/feathers');
const socketio = require('@feathersjs/socketio-client');
const socket = io();
const app = feathers();
app.configure(socketio(socket));
app.mixins.push((service, path) => {
service.mixin({
on(... args) {
const event = args[0];
// If it is a socket client service
if(service.connection && typeof service.connection.emit === 'function') {
service.connection.emit('subscribe', {
path, event
});
}
// Call the old `.on`
return this._super(... args);
}
})
}); Closing this issue but would be happy to help if someone would like to turn this into a plugin 😄 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
I'm trying to understand why Feathers can't automatically ignore the events user didn't subscribe to. From what I understand everything is pretty straightforward.
When we subscribe on an event, the client automatically emits a socketio event, something like this:
feathers.io.emit('subscribe', {service, event})
. On the server side we catch it and save like this:socket.feathers.subscriptions.push({service, event})
. After that we have all the information we need to filter all the events implicitly, sending to the client only relevant data. You just need to add that filter by default to every service.Is there a reason why you don't do this? Are you planning to implement such a mechanism?
The text was updated successfully, but these errors were encountered: