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

(#357) MappedProperty: should produce the current value on Advise #418

Merged
merged 2 commits into from
Jul 11, 2023

Conversation

ForNeVeR
Copy link
Collaborator

@ForNeVeR ForNeVeR commented Jul 1, 2023

Closes #357.

@ForNeVeR ForNeVeR requested a review from Iliya-usov July 1, 2023 13:58
@@ -375,7 +374,7 @@ public MappedProperty(IViewableProperty<T> source, Func<T, R> map)
{
mySource = source;
myMap = map;
Change = new MappedSink<T, R>(source.Change, myMap);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This fix is not correct because Cange shouldn't provide an initial state, usually it is a signal.
I recommend rewriting the Advise method in the MappedProperty class as follows:

public void Advise(Lifetime lifetime, Action<R> handler) => mySource.Advise(lifetime, x => handler(myMap(x)));

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, thanks, I'll take a look.

@ForNeVeR ForNeVeR self-assigned this Jul 5, 2023
@ForNeVeR ForNeVeR requested a review from Iliya-usov July 10, 2023 20:24
@Iliya-usov Iliya-usov merged commit 6a58715 into master Jul 11, 2023
7 checks passed
@ForNeVeR ForNeVeR deleted the im/357.mapped-property-advise branch July 12, 2023 08:43
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.

IReadonlyProperty<R> Select<T, R> (.net)
2 participants