-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(tree): make data source accept array or observable #9847
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
Conversation
src/cdk-experimental/tree/tree.ts
Outdated
this._data = new Array<T>(); | ||
|
||
if (this.dataSource) { | ||
if (this.dataSource instanceof DataSource) { |
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.
We can into problems with the table using instanceof
for this since people often create fakes for tests that are just object literals with a connect
method. @andrewseguin what did you end up doing?
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.
Updated. Using the same way as table now. Please take a look. Thanks!
src/cdk-experimental/tree/tree.ts
Outdated
dataStream = this._dataSource.connect(this); | ||
} else if (this._dataSource instanceof Observable) { | ||
dataStream = this._dataSource; | ||
} else if (this._dataSource instanceof Array) { |
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.
Use Array.isArray(...)
31ab6d2
to
7056d38
Compare
src/cdk/tree/tree.ts
Outdated
|
||
// Cannot use `instanceof DataSource` since the data source could be a literal with | ||
// `connect` function and may not extends DataSource. | ||
if ((this._dataSource as DataSource<T>).connect instanceof Function) { |
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.
I missed this in the table PR, but it should use typeof
rather than instanceof
since the former is generally more reliable for primitive types.
Also it should use the same checks for the instanceof DataSource
checks in the rest of the file (which I also missed in the table PR)
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.
Updated. Thanks for review!
d0ff86a
to
c6e06c1
Compare
c6e06c1
to
5174025
Compare
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.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.