Import
import { IndexValueAccessor } from '@rs-x/core';API Reference
Composite accessor service that selects the first matching accessor strategy (by priority) and delegates all read/write operations to that strategy.
import { IndexValueAccessor } from '@rs-x/core';import {
InjectionContainer,
RsXCoreInjectionTokens,
RsXCoreModule,
type IIndexValueAccessor,
} from '@rs-x/core';
await InjectionContainer.load(RsXCoreModule);
const accessor = InjectionContainer.get<IIndexValueAccessor>(
RsXCoreInjectionTokens.IIndexValueAccessor,
);
const model = {
user: { name: 'Ada' },
list: [10, 20, 30],
map: new Map([['x', 99]]),
};
console.log(accessor.getValue(model.user, 'name')); // Ada
console.log(accessor.getValue(model.list, 1)); // 20
console.log(accessor.getValue(model.map, 'x')); // 99import { Inject, RsXCoreInjectionTokens, type IIndexValueAccessor } from '@rs-x/core';
class MyConsumer {
constructor(
@Inject(RsXCoreInjectionTokens.IIndexValueAccessor)
private readonly dependency: IIndexValueAccessor,
) {}
}7 members in this class.
constructor(
@MultiInject(RsXCoreInjectionTokens.IIndexValueAccessorList) accessors: readonly IIndexValueAccessor[]
)Parameters
public applies(
context: unknown,
index: unknown
): booleanParameters
Returns
boolean
public getIndexes(
context: unknown,
index: unknown
): IterableIterator<unknown>Parameters
Returns
IterableIterator<unknown>
public getResolvedValue(
context: unknown,
index: unknown
): unknownParameters
Returns
unknown
public getValue(
context: unknown,
index: unknown
): unknownParameters
Returns
unknown
public hasValue(
context: unknown,
index: unknown
): booleanParameters
Returns
boolean
public setValue(
context: unknown,
index: unknown,
value: unknown
): voidParameters
Returns
void