For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to deal with state shared across Components?

Hi, given that you can choose the best approach that fits better for your project here are 3 different ways to achieve it in MauiReactor/C# that I can think of:

  1. Pass global state/parameters down to your component tree. For example, say you have a class that resembles your settings pass it down to your components:

class Settings
{
  public int MySettingValue {get;set;}
}

class MyComponent
{
   Settings? _settings;
    public MyComponent Settings(Settings settings)
    {
       _settings = settings;
      return this;
    }

    public override VisualNode Render()
    {
      //use _settings and pass down to components used here _settings object
    }
}
  1. Use dependency injection to "inject" your global state/parameters:

  1. Use the "Parameters" feature provided by MauiReactor: it allows you to create a Parameter in a parent component and access it in read-write mode from child components:

for more info on this specific feature please take a look at:

Last updated