Skip to content

Make DispatcherExtensions with DispatchIfRequired() and FindDispatcher() available #29258

@jBijsterboschNL

Description

@jBijsterboschNL

Description

I would love to have the DispatcherExtensions to be exposed so they are available outside Maui as well. There are a few very useful extension methods DispatchIfRequired() and FindDispatcher() that are useful for every Maui project. Also that EnsureDispatcher() is called in these methods is very helpful. Unfortunately these extension methods are internal. If this could be made public, a lot of Maui developers would be happy with this 😄

Public API Changes

// easily find dispatcher from every BindableObject
Grid grid = new();
var dispatcher = grid.FindDispatcher();

// only dispatch when required in one call (instead of first checking dispatcher.IsRequired and then calling dispatcher.Dispatch())
dispatcher.DispatchIfRequired(() => /* do something */);

Intended Use-Case

The FindDispatcher() and DispatchIfRequired() are very useful and the EnsureDispatcher() logic that is built within these methods are making sure that the dispatcher is found properly. For every project these logic is re-created over and over, but it is already inside Maui itself! Only not available outside Maui...

Metadata

Metadata

Assignees

Labels

p/1Work that is important, and has been scheduled for release in this or an upcoming sprintproposal/open

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions