-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix getDirectory for parameters #39
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,7 +209,13 @@ export class EmberClient extends EventEmitter<EmberClientEvents> { | |
cb, | ||
}) | ||
|
||
return this._sendCommand<RootElement>(node, command, ExpectResponse.HasChildren) | ||
return this._sendCommand<RootElement>( | ||
node, | ||
command, | ||
node.contents.type == 'PARAMETER' | ||
? ExpectResponse.None | ||
: ExpectResponse.HasChildren | ||
) | ||
} | ||
async subscribe( | ||
node: RootElement | Array<RootElement>, | ||
|
@@ -388,24 +394,24 @@ export class EmberClient extends EventEmitter<EmberClientEvents> { | |
const i = pathArr.shift() | ||
if (!i) break // TODO - this will break the loop if the path was `1..0` | ||
if (!tree) break | ||
let next = getNextChild(tree, i) | ||
if (!next) { | ||
const req = await this.getDirectory(tree) | ||
tree = (await req.response) as NumberedTreeNode<EmberElement> | ||
next = getNextChild(tree, i) | ||
} | ||
tree = next | ||
const req = await this.getDirectory(tree) | ||
tree = (await req.response) as NumberedTreeNode<EmberElement> | ||
tree = getNextChild(tree, i) | ||
if (!tree) throw new Error(`Could not find node ${i} on given path ${numberedPath.join()}`) | ||
if (tree?.number !== undefined) numberedPath.push(tree.number) | ||
} | ||
|
||
if (cb && numberedPath) { | ||
this._subscriptions.push({ | ||
path: numberedPath.join('.'), | ||
cb, | ||
}) | ||
if (tree) { | ||
const req = await this.getDirectory(tree) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The constant is never used so it is not necessary to assign it |
||
} | ||
|
||
// this resulted in doubled subscription because getDirectory() adds the element as well | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what's going on here. Since the callback is never passed to the getDirectory call it should not cause a double subscription. |
||
// if (cb && numberedPath) { | ||
// this._subscriptions.push({ | ||
// path: numberedPath.join('.'), | ||
// cb, | ||
// }) | ||
// } | ||
|
||
return tree | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you help me understand why this is needed in regards to the main issue this PR addresses?
The reason I am asking it makes it such that every time a library user uses this call the library will fetch all nodes in the path even though we have already fetched these before and can just look at them locally.