toReactive method
Creates a reactive map with custom middleware from this map.
This method is similar to reactive, but allows you to provide middleware to customize the behavior of the reactive map.
Parameters:
middlewares: A list of FluxivityMiddleware instances to apply to the reactive map.
Example:
// Create a reactive map with logging middleware
final settings = {'notifications': true, 'darkMode': false}.toReactive(
middlewares: [LoggingMiddleware<Map<String, bool>>()],
);
settings.value['sound'] = true; // This will be logged by the middleware
settings.value = Map.from(settings.value); // Trigger notification and logging
Implementation
Reactive<Map<K, V>> toReactive(
{List<FluxivityMiddleware<Map<K, V>>>? middlewares}) {
return Reactive<Map<K, V>>(Map<K, V>.from(this), middlewares: middlewares);
}