-
Notifications
You must be signed in to change notification settings - Fork 1
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
Unobserve attributes #3
base: master
Are you sure you want to change the base?
Conversation
@semmel thank you very much for the PR. Sorry for the delay, for some reason I am not receiving notifications for this repo. Also regarding roll-up, in theory running |
@@ -34,7 +34,7 @@ This is invoked when an attribute from the `observedAttributes` list is added, c | |||
removed. This could be useful to make network request for updating the data. | |||
|
|||
```javascript | |||
onAttributeChanged(element, ({ name, current }) => { | |||
let unsubscribe = onAttributeChanged(element, ({ name, current }) => { |
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 we use const
instead of let
here? Since is not going to change it make more sense a const.
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.
Done - no problem.
element = document.querySelector('attribute-test-element'); | ||
|
||
onAttributeChanged(element, ({name, current, old}) => { | ||
if (name !== "foo") { |
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 could use a mock function and check if that function was called or not called in the other test. In that way the test will be simpler and we don't need to throw errors
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.
Sorry, I don't get it 🤔. Could you describe it more?
I did that, but I could not find any differences :-/
|
For wrapping attribute changes in my reactive streams I needed a way to unsubscribe the callback again.
This PR also adds a few tests around
onAttributeChanged
.(I did not quite understand the need for the additional
jest
tests, why is karma not sufficient?)Hope all this is non-breaking since I use the return value of
onAttributeChanged
which is up to now not documented.I did not build the doc files, just edited the sources.
I needed to bump karma-rollup-preprocessor because the old is not compatible with my more recent rollup.