Import
import { GlobalIndexAccessor } from '@rs-x/core';API Reference
Global fallback accessor used by the index-value-accessor pipeline. It resolves keys from globalThis (for example Math, Date, console) when the context is globalThis.
import { GlobalIndexAccessor } from '@rs-x/core';import {
InjectionContainer,
RsXCoreInjectionTokens,
RsXCoreModule,
type IGlobalIndexAccessor,
} from '@rs-x/core';
await InjectionContainer.load(RsXCoreModule);
const accessor = InjectionContainer.get<IGlobalIndexAccessor>(
RsXCoreInjectionTokens.IGlobalIndexAccessor,
);
console.log(accessor.hasValue(globalThis, 'Math')); // true
const mathObj = accessor.getValue(globalThis, 'Math');
console.log(typeof mathObj); // objectimport { Inject, RsXCoreInjectionTokens, type IGlobalIndexAccessor } from '@rs-x/core';
class MyConsumer {
constructor(
@Inject(RsXCoreInjectionTokens.IGlobalIndexAccessor)
private readonly dependency: IGlobalIndexAccessor,
) {}
}6 members in this class.
public applies(
context: unknown,
index: string
): booleanParameters
Returns
boolean
public getIndexes(_: unknown): IterableIterator<string>Parameters
Returns
IterableIterator<string>
public getResolvedValue(
context: unknown,
index: string
): unknownParameters
Returns
unknown
public getValue(
_: unknown,
index: string
): unknownParameters
Returns
unknown
public hasValue(
_: unknown,
index: string
): booleanParameters
Returns
boolean
public setValue(
_: unknown,
index: string
): voidParameters
Returns
void