API Reference

MethodAccessorclass

Method-call accessor implementation used by the index-value-accessor pipeline. It reads cached method-call results by function-call index; it does not execute methods directly.

Quick facts
Kind
class
Implements
IMethodAccessor
Members
7
Package
@rs-x/core

Import

import { MethodAccessor } from '@rs-x/core';

Example

import {
  InjectionContainer,
  RsXCoreInjectionTokens,
  RsXCoreModule,
  type IFunctionCallIndexFactory,
  type IFunctionCallResultCache,
  type IMethodAccessor,
} from '@rs-x/core';

await InjectionContainer.load(RsXCoreModule);

const accessor = InjectionContainer.get<IMethodAccessor>(
  RsXCoreInjectionTokens.IMethodAccessor,
);
const indexFactory = InjectionContainer.get<IFunctionCallIndexFactory>(
  RsXCoreInjectionTokens.IFunctionCallIndexFactory,
);
const resultCache = InjectionContainer.get<IFunctionCallResultCache>(
  RsXCoreInjectionTokens.IFunctionCallResultCache,
);

const context = { sum: (a: number, b: number) => a + b };

Constructor injection example

import { Inject, RsXCoreInjectionTokens, type IMethodAccessor } from '@rs-x/core';

class MyConsumer {
  constructor(
    @Inject(RsXCoreInjectionTokens.IMethodAccessor)
    private readonly dependency: IMethodAccessor,
  ) {}
}

Members

7 members in this class.

constructor
constructorpublic
constructor(
  @Inject(RsXCoreInjectionTokens.IFunctionCallResultCache) private readonly _functionCallResultCache: IFunctionCallResultCache
)

Parameters

Name
Type
Required
_functionCallResultCache
IFunctionCallResultCache
required
applies
methodpublic
public applies(
  context: unknown,
  index: IFunctionCallIndex
): boolean

Parameters

Name
Type
Required
context
unknown
required
index
IFunctionCallIndex
required

Returns

boolean

getIndexes
methodpublic
public getIndexes(): IterableIterator<IDisposableFunctionCallIndex>

Parameters

No parameters.

Returns

IterableIterator<IDisposableFunctionCallIndex>

getResolvedValue
methodpublic
public getResolvedValue(
  context: object,
  index: IFunctionCallIndex
): unknown

Parameters

Name
Type
Required
context
object
required
index
IFunctionCallIndex
required

Returns

unknown

getValue
methodpublic
public getValue(
  context: unknown,
  index: IFunctionCallIndex
): unknown

Parameters

Name
Type
Required
context
unknown
required
index
IFunctionCallIndex
required

Returns

unknown

hasValue
methodpublic
public hasValue(
  context: object,
  index: IFunctionCallIndex
): boolean

Parameters

Name
Type
Required
context
object
required
index
IFunctionCallIndex
required

Returns

boolean

setValue
methodpublic
public setValue(
  _: object,
  index: IFunctionCallIndex
): void

Parameters

Name
Type
Required
_
object
required
index
IFunctionCallIndex
required

Returns

void