Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow resubscribing to an object

See original GitHub issue

Hi 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:[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({});

What’s interesting though, is that I don’t get the error when always creating a new object, like so:

var dop = require("dop");

Does unsubscribe destroy the object on the server or something?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

VanCodingcommented, Jun 22, 2018

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 😃

VanCodingcommented, Jun 22, 2018

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! 😃

Read more comments on GitHub >

github_iconTop 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 -
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found