KEMBAR78
Create convenience methods for adding behavior to a mapper by hartez · Pull Request #1859 · dotnet/maui · GitHub
Skip to content

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Jul 29, 2021

Convenience extension methods for adding extra behavior before/after an existing mapping.

Adds two extensions:
propertyMapper.AppendToMapping(string key, Action<TViewHandler, TVirtualView> method)
propertyMapper.PrependToMapping(string key, Action<TViewHandler, TVirtualView> method)

Given a mapper like

var mapper = new PropertyMapper<IView, IViewHandler>
{
	[nameof(IView.Background)] = (r, v) => Debug.WriteLine("Original behavior")
};

We can do this

mapper.AppendToMapping(nameof(IView.Background), (h, v) => Debug.WriteLine("Additional behavior"));

And the output when the Background property updates would be

Original behavior
Additional behavior

Prepend works the other way around - the new behavior runs first.

@PureWeen PureWeen merged commit 5179ffc into main Jul 31, 2021
@PureWeen PureWeen deleted the propertymapperextensions branch July 31, 2021 18:14
@Redth Redth added this to the 6.0.100-preview.7 milestone Aug 2, 2021
@samhouts samhouts added the area-controls-map Map / Maps label Jul 10, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Jul 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@samhouts samhouts added the fixed-in-6.0.100-rc.1.7 Look for this fix in 6.0.100-rc.1.7! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-controls-map Map / Maps fixed-in-6.0.100-rc.1.7 Look for this fix in 6.0.100-rc.1.7!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants