feathersjs-ecosystem / feathers-vuex

Integration of FeathersJS, Vue, and Nuxt for the artisan developer

Home Page:https://vuex.feathersjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: Capability to subscribe events (just receive needed events, not all)

fratzinger opened this issue · comments

Just tinkering/thinking out loud. Nothing really crucial. It's open for discussion. Maybe it came up in the feathers-world somewhere (which I don't know of). I could imagine it's not a real world problem at all and would be quite over engineered. But I think it's worth to think about.

@J3m5 made a point (see quote below). It's about a mechanism that allows to subscribe for necessary channel-updates. I guess as of now, there's no performant way of telling feathers which events are currently important and which can be easily ignored. Feathers-Vuex maybe is capable of this doing under the hood.

We could create one channel per service at startup, and then, when a client call a service, register its connection to the corresponding channel if they have the permissions.

Because apart for a notification system, I don't see any reason to receive events for resources you didn't requested yet.
This could be optional of course, (opt-in or opt-out).

This would reduce the load on the server by reducing the checks for the permissions and the sending of the events.
It would also reduce the amount of data stored on the client if a store is used.

The only downside is that, for each request, it would check if the client is already in the channel ( done automatically in the channels when you add a connection if I remember correctly)

- @J3m5 from fratzinger/feathers-casl#10 (comment)

This could automatically implemented with mixins and use-hooks, somehow. They could register a notification system under the hood without the need for a manual subscribe/unsubscribe pattern (which could be quite tedious to keep maintained). I guess there are quite a few edge cases. It even get's more complex for actions and Model-methods.

I'm curious about your opinion.

This may be an applicable article: https://blog.feathersjs.com/feathersjs-channel-subscriptions-647c771ca6c8. I believe this is a server-centric solution.

This article is a good starting point. Recently I thought about making a composition utility, something like:

const { useReactive} from '@feathers/vuex'

useReactive([
  'users',
  'comments'
])

useReactive then globally handles onMounted and on Destroyed to subscribe/unsubscribe to call create/remove methods on the server.

Does that make sense anyhow? 😆