graycoreio/daffodil

View on GitHub
libs/customer-payment/state/src/reducers/payment-entities/adapter.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { createEntityAdapter } from '@ngrx/entity';

import {
  DaffOperationEntity,
  daffCreateOperationEntityStateAdapter,
  DaffOperationEntityStateAdapter,
} from '@daffodil/core/state';
import { DaffCustomerPayment } from '@daffodil/customer-payment';

/**
 * Customer Payment Entities Adapter for changing/overwriting entity state.
 */
export const daffCustomerPaymentEntitiesAdapter = (() => {
  let cache;
  return <T extends DaffCustomerPayment = DaffCustomerPayment>(): DaffOperationEntityStateAdapter<T> =>
    cache = cache || daffCreateOperationEntityStateAdapter(createEntityAdapter<DaffOperationEntity<T>>());
})();