Skip to content
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

Update on value change #68

Merged
merged 4 commits into from
Feb 22, 2021
Merged

Update on value change #68

merged 4 commits into from
Feb 22, 2021

Conversation

yha
Copy link
Contributor

@yha yha commented Feb 4, 2021

latest_change(obs) to only observe value changes. Ref #5

Copy link
Member

@twavv twavv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think latest_change is the best name for this.

Maybe value_change? Still not a fan of that either...

src/Observables.jl Outdated Show resolved Hide resolved
@twavv
Copy link
Member

twavv commented Feb 4, 2021

Maybe just rename the function to observe_value (to match observe).

@yha
Copy link
Contributor Author

yha commented Feb 5, 2021

Maybe just rename the function to observe_value (to match observe).

observe is not documented, and looking at its implementation, I'm not sure what it's for, or what the connection is.
latest_change matches async_latest. But I think value_change works too.
Perhaps each_change? on(each_change(obs)) reads nicely, but it also kind of suggests an iterable.

@timholy
Copy link
Member

timholy commented Feb 6, 2021

Maybe notify_changed or monitor_changed?

@yha
Copy link
Contributor Author

yha commented Feb 8, 2021

I think the most important aspect for the name to be discoverable and reasonably intuitive is that it includes the word "change".
If the name is to contain a verb, I would prefer observe over notify or monitor, because the latter seem to me to suggest it does something extra beside an Observable transformation (notify in particular suggest it has something to do with tasks).
I think observe_changes is fine, as is value_change/value_changes, or simply changes.

@twavv
Copy link
Member

twavv commented Feb 8, 2021

I don't care that much, I think we've entered bikeshedding territory.

... but while we're here, how about debounce_value? I think keeping value is important.

@yha
Copy link
Contributor Author

yha commented Feb 8, 2021

how about debounce_value?

I don't understand what that means. "debounce"?

I think keeping value is important.

Why? The default for eq compares by value, but you can pass other functions (like ===).

@yha
Copy link
Contributor Author

yha commented Feb 8, 2021

So after searching for that term, it looks like debounce in JS is basically the same thing as async_latest here. I can see now how debounce_value is similar (which is why I used "latest"). But it seems odd to use the term here and not in async_latest.

@timholy
Copy link
Member

timholy commented Feb 10, 2021

Since there's no consensus, how about we let the author @yha make the decision? I'll throw out filter_changed, follow_changes, and changes_only as additional menu items for you to choose from. I like each_change and observe_changes. I'd only ask that we not choose anything with debounce in it as I find that term almost incomprehensible upon first look.

@twavv
Copy link
Member

twavv commented Feb 10, 2021

I was actually thinking about this yesterday.

I think it should be a new type (whether that be ChangeObservable or ValueObservable or whatever else). Not using a type seems to disallow off-ing the observable (at least it won't off the inner/wrapped observable).

I'll also defer to whatever y'all think, but I don't like using "latest". Maybe go see what Rx calls this and copy that.

@yha
Copy link
Contributor Author

yha commented Feb 10, 2021

Not using a type seems to disallow off-ing the observable (at least it won't off the inner/wrapped observable).

Do you mean removing removing the connection to the wrapped observable? i.e. calling off on the result of on inside the implementation? This is also not possible with map, async_latest, and throttle.
How does using a type make this easier?

Maybe go see what Rx calls this and copy that.

Rx calls this distinct_until_changed, as you have noted in the original issue. I don't think that's a good name either. Seems pretty opaque unless you are already familiar with Rx's distinct.

@timholy
Copy link
Member

timholy commented Feb 10, 2021

Let's give others a short window to comment and then merge. (Bump if I forget to come back.)

@timholy timholy merged commit 0f94e69 into JuliaGizmos:master Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants