API Reference

IndexWatchRuleFactoryclass

Default factory used by the runtime to create watch rules for identifier/index based observation. Created rules are stable per (context, index) and can be disposed when no longer needed.

Overview

Index-watch-rule contracts, registry, and default recursive/non-recursive watch rules.

Import

import { IndexWatchRuleFactory } from '@rs-x/state-manager';

Example

import { IndexWatchRuleFactory } from '@rs-x/state-manager';

const factory = new IndexWatchRuleFactory();
const rule = factory.create({ user: { profile: {} } }, 'user');

// rule can be passed to watchState(..., { indexWatchRule: rule })
// or rsx(...)(model, rule)
rule.dispose();

Constructor injection example

import { Inject } from '@rs-x/core';
import {
  RsXStateManagerInjectionTokens,
  type IIndexWatchRuleFactory,
} from '@rs-x/state-manager';

class MyConsumer {
  constructor(
    @Inject(RsXStateManagerInjectionTokens.IIndexWatchRuleFactory)
    private readonly dependency: IIndexWatchRuleFactory,
  ) {}
}

Members

2 members in this class.

constructor
constructorpublic
constructor()

Parameters

No parameters.

create
methodpublic
public create(
  context: unknown,
  index: unknown
): IIndexWatchRule

Parameters

NameTypeRequired
contextunknownrequired
indexunknownrequired