Skip to main content
cngx-src documentation

CNGX_LOCAL_ITEMS_BUFFER_FACTORY

Tokenv0.1.0

InjectionToken<CngxLocalItemsBufferFactory>

Description#

Factory token for LocalItemsBuffer. Default createLocalItemsBuffer. Override for audit logging, backend sync, or localStorage persistence.

bootstrapApplication(App, {
  providers: [
    {
      provide: CNGX_LOCAL_ITEMS_BUFFER_FACTORY,
      useValue: <T>(compareWith) => {
        const buf = createLocalItemsBuffer<T>(compareWith);
        return {
          items: buf.items,
          patch(item) { auditLog('patch', item); buf.patch(item); },
          clear() { auditLog('clear'); buf.clear(); },
        };
      },
    },
  ],
});

Type#

InjectionToken<CngxLocalItemsBufferFactory>

Provided in#

'root'