allow resubscribing to an object
See original GitHub issueHi and thanks for this awesome library!! 😃 I’m doing my home automation with it and it works pretty well so far.
But I encountered a situation where I’d like to periodically unsubscribe and resubscribe to an object, and it does not seem to work currently. It throws the following error when doing it: TypeError: dop.data.object[node.owner[object_owner_id]] is undefined
example client
var dop = require("dop");
var client = dop.connect({url:'ws://'+location.hostname+':4444'});
client.on("connect",async ()=>{
var x = await client.subscribe("x");
await client.unsubscribe(x);
x = await client.subscribe("x");
})
example server
var dop = require("dop");
var x = dop.register({});
dop.onSubscribe(name=>x);
dop.listen();
What’s interesting though, is that I don’t get the error when always creating a new object, like so:
var dop = require("dop");
dop.onSubscribe(name=>dop.register({}));
dop.listen();
Does unsubscribe
destroy the object on the server or something?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to subscribe object from service in Angular 2/5?
You can create a subscription in your service that notifies if event list changed eventChanged = new Subject<Event[]>();.
Read more >Subscriptions - Apollo GraphQL Docs
Like queries, subscriptions enable you to fetch data. ... Instead, you can fetch the object's initial state with a query, and your server...
Read more >Subscribing a User - web.dev
The first step is to get permission from the user to send them push messages and then we can get our hands on...
Read more >Manually resubscribe a contact
Click the Contacts tab. Search for the contact you want to resubscribe. Next to the contact, click ... > Resubscribe.
Read more >How to subscribe to and unsubscribe from events - C# ...
To subscribe to events by using an anonymous function publisher. RaiseCustomEvent += (object o, CustomEventArgs e) => { string s = o. ToString( ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t use any established smart home system. Since I’m a programmer and it’s my own house, I like to do it my own way and create something unique. I just use a raspberry PI as central server, to which all devices are connected in some way (sometimes directly over LAN (relays), sometimes over WIFI (LIFX bulbs), sometimes over a bridge to some protocol.
I discovered dop after a long search through the NPM registry 😃
In case you’re interested what I’m doing in my home, keep reading, if not, just ignore this comment 😉
I’ve built one or multiple touchscreens into the walls of all rooms of my house, which display buttons or other control elements to toggle the lights, the blinds, see the temperature, starting / stopping music, controlling the volume etc. Every tablet can control everything in the house, but by default it only shows the controls for the room it’s installed in, but you can also navigate to what any other tablet is showing.
And this is where subscribing/unsubscribing comes in: Every device in my house is represented by a dop object, that the tablets can subscribe to. But the tablets only subscribe to devices that they do show controls for on the screen. If you show another control page, the devices shown on the previous page automatically get unsubscribed and only get subscribed again when navigating back to that page.
This way, every tablet only subscribes to the devices it needs/cares for and does not get updates of the whole building. This saves a lot of bandwidth.
dop really fits this use case pretty well and I’m glad you invested the time realize it. Thank you very much for this! 😃