node-tradfri-client icon indicating copy to clipboard operation
node-tradfri-client copied to clipboard

Investigate if all device objects should be linked to the client instance by default

Open erspearson opened this issue 5 years ago • 3 comments

link(client: OperationProvider): this;

is curiously missing from its definition file IPSOObject.d.ts

Also - any reason why the cloned objects (e.g. Groups) found in e.g. tradfri.groups[] collection are not linked back to the client they sit under? Linking is done after cloning to the emitted copies.

erspearson avatar Mar 09 '19 18:03 erspearson

I'll have to look into that.

AlCalzone avatar Mar 10 '19 07:03 AlCalzone

Ah, I see - link(client: OperationProvider): this; was tagged as @internal on 8 January 2018 replacing the comment 'INTERNAL USE ONLY'

So it looks like your intention for the simplified API is that it should only be used on the objects emitted by the events, not on the ones found in tradfri.devices[], tradfri.groups[] etc

As a new user, VSCode lead me into trying to use tradfri.groups[131075].group.turnOn() but that gives the runtime error that the object is 'not linked to a client instance' which seems surprising at the time since it came directly from the client if you see what I mean.

erspearson avatar Mar 10 '19 12:03 erspearson

As a new user, VSCode lead me into trying to use ...

This might be a valid thing to do nonetheless. I'll let you know if that is something that should be supported.

AlCalzone avatar Mar 10 '19 13:03 AlCalzone