From abae5a54b0f1b98a5f2e7664717970aa760d9023 Mon Sep 17 00:00:00 2001 From: Shlomi Assaf Date: Thu, 13 Jun 2019 03:06:11 +0300 Subject: [PATCH] refactor: workaround tree shakable expression in ngrid/state --- libs/ngrid-material/package.json | 4 +- libs/ngrid/package.json | 2 +- libs/ngrid/src/lib/ext/table-plugin.ts | 4 + .../lib/core/built-in-handlers/_register.ts | 9 + .../built-in-handlers/column-def/children.ts | 256 +++++++++--------- .../built-in-handlers/column-def/index.ts | 170 ++++++------ .../built-in-handlers/column-order/index.ts | 72 ++--- .../grid-primitives/index.ts | 30 +- .../src/lib/core/built-in-handlers/index.ts | 5 - libs/ngrid/state/src/lib/core/index.ts | 2 - libs/ngrid/state/src/lib/state-plugin.ts | 6 +- package.json | 2 +- 12 files changed, 289 insertions(+), 273 deletions(-) create mode 100644 libs/ngrid/state/src/lib/core/built-in-handlers/_register.ts diff --git a/libs/ngrid-material/package.json b/libs/ngrid-material/package.json index 20f6a1aad..f5194d358 100644 --- a/libs/ngrid-material/package.json +++ b/libs/ngrid-material/package.json @@ -1,8 +1,8 @@ { "name": "@pebula/ngrid-material", - "version": "1.0.0-alpha.21", + "version": "1.0.0-alpha.22", "peerDependencies": { "@angular/material": "^7.3.1", - "@pebula/ngrid": "1.0.0-alpha.21" + "@pebula/ngrid": "1.0.0-alpha.22" } } diff --git a/libs/ngrid/package.json b/libs/ngrid/package.json index 5a73e0d85..1a0c2d280 100644 --- a/libs/ngrid/package.json +++ b/libs/ngrid/package.json @@ -1,6 +1,6 @@ { "name": "@pebula/ngrid", - "version": "1.0.0-alpha.21", + "version": "1.0.0-alpha.22", "peerDependencies": { "@angular/common": "^7.2.3", "@angular/core": "^7.2.3", diff --git a/libs/ngrid/src/lib/ext/table-plugin.ts b/libs/ngrid/src/lib/ext/table-plugin.ts index 8b0ddf86c..be11cc68e 100644 --- a/libs/ngrid/src/lib/ext/table-plugin.ts +++ b/libs/ngrid/src/lib/ext/table-plugin.ts @@ -9,9 +9,13 @@ export interface TablePluginMetadata

void; } export function TablePlugin(metadata: TablePluginMetadata) { + if (metadata.runOnce) { + metadata.runOnce(); + } return target => { PLUGIN_STORE.set(metadata.id, { ...metadata, target }); } diff --git a/libs/ngrid/state/src/lib/core/built-in-handlers/_register.ts b/libs/ngrid/state/src/lib/core/built-in-handlers/_register.ts new file mode 100644 index 000000000..f3c571ef6 --- /dev/null +++ b/libs/ngrid/state/src/lib/core/built-in-handlers/_register.ts @@ -0,0 +1,9 @@ +import { registerGridHandlers } from './grid-primitives/index'; +import { registerColumnOrderHandlers } from './column-order/index'; +import { registerColumnDefHandlers } from './column-def/index'; + +export function registerBuiltInHandlers() { + registerGridHandlers(); + registerColumnOrderHandlers(); + registerColumnDefHandlers(); +} diff --git a/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/children.ts b/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/children.ts index a6dab1ce1..e7398db53 100644 --- a/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/children.ts +++ b/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/children.ts @@ -1,144 +1,146 @@ import { PblColumnTypeDefinition } from '@pebula/ngrid'; import { createStateChunkHandler } from '../../handling'; -/* ====================================================================================================================================================== */ - -createStateChunkHandler('dataColumn') - .requiredKeys('id', 'prop') - .handleKeys( - 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) - 'headerType', 'footerType', 'sort', 'sortAlias', 'editable', 'pin' // All Optional - ) - .serialize( (key, ctx) => { - const c = ctx.data.activeColumn || ctx.data.pblColumn; - if (c) { +export function registerColumnDefChildHandlers() { + /* ====================================================================================================================================================== */ + + createStateChunkHandler('dataColumn') + .requiredKeys('id', 'prop') + .handleKeys( + 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) + 'headerType', 'footerType', 'sort', 'sortAlias', 'editable', 'pin' // All Optional + ) + .serialize( (key, ctx) => { + const c = ctx.data.activeColumn || ctx.data.pblColumn; + if (c) { + switch (key) { + case 'prop': + return c.orgProp; + default: + break; + } + } + + const value = c ? c[key] : ctx.source[key]; + switch (key) { - case 'prop': - return c.orgProp; + case 'sort': + if (typeof value === 'boolean') { + return value; + } else { + return; + } default: break; } - } - - const value = c ? c[key] : ctx.source[key]; - switch (key) { - case 'sort': - if (typeof value === 'boolean') { - return value; - } else { - return; + return value; + }) + .deserialize( (key, stateValue, ctx) => { + const { activeColumn } = ctx.data; + if (activeColumn) { + switch (key) { + case 'width': + activeColumn.updateWidth(true, stateValue as any); + break; } - default: - break; - } - - return value; - }) - .deserialize( (key, stateValue, ctx) => { - const { activeColumn } = ctx.data; - if (activeColumn) { - switch (key) { - case 'width': - activeColumn.updateWidth(true, stateValue as any); - break; } - } - if (ctx.source) { - switch (key) { - case 'prop': - return; - case 'type': - case 'headerType': - case 'footerType': - const typeValue = ctx.source[key]; - const stateTypeDef: PblColumnTypeDefinition = stateValue as any; - if (stateTypeDef && typeof stateTypeDef !== 'string' && typeValue && typeof typeValue !== 'string') { - typeValue.name = stateTypeDef.name; - if (stateTypeDef.data) { - typeValue.data = Object.assign(typeValue.data || {}, stateTypeDef.data); - } + if (ctx.source) { + switch (key) { + case 'prop': return; - } - break; + case 'type': + case 'headerType': + case 'footerType': + const typeValue = ctx.source[key]; + const stateTypeDef: PblColumnTypeDefinition = stateValue as any; + if (stateTypeDef && typeof stateTypeDef !== 'string' && typeValue && typeof typeValue !== 'string') { + typeValue.name = stateTypeDef.name; + if (stateTypeDef.data) { + typeValue.data = Object.assign(typeValue.data || {}, stateTypeDef.data); + } + return; + } + break; + } + ctx.source[key] = stateValue; + } + + }) + .register(); + + /* ====================================================================================================================================================== */ + + createStateChunkHandler('dataMetaRow') + .handleKeys('rowClassName', 'type') // All Optional + .serialize( (key, ctx) => { + const active = ctx.data.active || ctx.source; + if (active) { + return active[key]; } - ctx.source[key] = stateValue; - } - - }) - .register(); - -/* ====================================================================================================================================================== */ - -createStateChunkHandler('dataMetaRow') - .handleKeys('rowClassName', 'type') // All Optional - .serialize( (key, ctx) => { - const active = ctx.data.active || ctx.source; - if (active) { - return active[key]; - } - }) - .deserialize( (key, stateValue, ctx) => ctx.source[key] = stateValue ) - .register(); - -/* ====================================================================================================================================================== */ - -createStateChunkHandler('metaRow') - // Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column - .handleKeys( - 'rowClassName', 'type', // All Optional like dataMetaRow - 'rowIndex', // Required + }) + .deserialize( (key, stateValue, ctx) => ctx.source[key] = stateValue ) + .register(); + + /* ====================================================================================================================================================== */ + + createStateChunkHandler('metaRow') + // Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column + .handleKeys( + 'rowClassName', 'type', // All Optional like dataMetaRow + 'rowIndex', // Required + ) + .serialize( (key, ctx) => { + return ctx.source[key]; + }) + .deserialize( (key, stateValue, ctx) => { + + }) + .register(); + + /* ====================================================================================================================================================== */ + + createStateChunkHandler('metaGroupRow') + // Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column + .handleKeys( + 'rowClassName', 'type', // All Optional like dataMetaRow + 'rowIndex', // Required + ) + .serialize( (key, ctx) => { + return ctx.source[key]; + }) + .deserialize( (key, stateValue, ctx) => { + + }) + .register(); + + /* ====================================================================================================================================================== */ + + createStateChunkHandler('metaColumn') + .requiredKeys('kind', 'rowIndex') + .handleKeys( + 'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) ) - .serialize( (key, ctx) => { - return ctx.source[key]; - }) - .deserialize( (key, stateValue, ctx) => { + .serialize( (key, ctx) => { + return ctx.source[key]; + }) + .deserialize( (key, stateValue, ctx) => { - }) - .register(); + }) + .register(); -/* ====================================================================================================================================================== */ + /* ====================================================================================================================================================== */ -createStateChunkHandler('metaGroupRow') - // Note that we are not handling `cols`, this should be called from the parent, as a different child chunk handling process for each column - .handleKeys( - 'rowClassName', 'type', // All Optional like dataMetaRow - 'rowIndex', // Required + createStateChunkHandler('metaGroupColumn') + .requiredKeys('prop', 'rowIndex', 'span') + .handleKeys( + 'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) ) - .serialize( (key, ctx) => { - return ctx.source[key]; - }) - .deserialize( (key, stateValue, ctx) => { - - }) - .register(); - -/* ====================================================================================================================================================== */ - -createStateChunkHandler('metaColumn') - .requiredKeys('kind', 'rowIndex') - .handleKeys( - 'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) - ) - .serialize( (key, ctx) => { - return ctx.source[key]; - }) - .deserialize( (key, stateValue, ctx) => { - - }) - .register(); - -/* ====================================================================================================================================================== */ - -createStateChunkHandler('metaGroupColumn') - .requiredKeys('prop', 'rowIndex', 'span') - .handleKeys( - 'id', 'label', 'css', 'type', 'width', 'minWidth', 'maxWidth', // PblNgridBaseColumnState (all optional) - ) - .serialize( (key, ctx) => { - return ctx.source[key]; - }) - .deserialize( (key, stateValue, ctx) => { - - }) - .register(); + .serialize( (key, ctx) => { + return ctx.source[key]; + }) + .deserialize( (key, stateValue, ctx) => { + + }) + .register(); +} diff --git a/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/index.ts b/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/index.ts index e37b720ab..db315bd80 100644 --- a/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/index.ts +++ b/libs/ngrid/state/src/lib/core/built-in-handlers/column-def/index.ts @@ -3,7 +3,7 @@ import { createStateChunkHandler } from '../../handling'; import { stateVisor } from '../../state-visor'; import { StateChunks, PblNgridStateChunkContext } from '../../models/index'; import { PblNgridMetaRowSetState, PblNgridMetaColumnState, PblNgridGroupColumnState, PblNgridColumnDefinitionSetState } from './model'; - +import { registerColumnDefChildHandlers } from './children'; function runChildChunksForRowMetaColumns(childChunkId: TChild, ctx: PblNgridStateChunkContext<"columns">, columns: TCol[]) { const stateColumns = []; @@ -55,97 +55,99 @@ function runChildChunksForRowDataColumns(mode: 's' | 'd', state: PblNgridColumnD } } -stateVisor.registerRootChunkSection( - 'columns', - { - sourceMatcher: ctx => ctx.grid.columns, - stateMatcher: state => state.columns || (state.columns = { - table: { - cols: [], - }, - header: [], - footer: [], - headerGroup: [], - }) - } -); +export function registerColumnDefHandlers() { + stateVisor.registerRootChunkSection( + 'columns', + { + sourceMatcher: ctx => ctx.grid.columns, + stateMatcher: state => state.columns || (state.columns = { + table: { + cols: [], + }, + header: [], + footer: [], + headerGroup: [], + }) + } + ); -createStateChunkHandler('columns') - .handleKeys('table', 'header', 'headerGroup', 'footer') - .serialize( (key, ctx) => { - switch (key) { - case 'table': - const state: PblNgridColumnDefinitionSetState['table'] = { cols: [] }; - runChildChunkForDataMetaRows('s', state, ctx); - runChildChunksForRowDataColumns('s', state, ctx); - return state; - case 'header': - case 'footer': - const source = ctx.source[key]; - if (source && source.length > 0) { - const rows = []; - for (const row of source) { - const active = ctx.extApi.columnStore.metaColumnIds[key].find( r => !r.isGroup && r.rowDef.rowIndex === row.rowIndex ); - const r: PblNgridMetaRowSetState = {} as any; - ctx.runChildChunk('metaRow', r, row); - r.cols = runChildChunksForRowMetaColumns('metaColumn', ctx, row.cols); - rows.push(r); + createStateChunkHandler('columns') + .handleKeys('table', 'header', 'headerGroup', 'footer') + .serialize( (key, ctx) => { + switch (key) { + case 'table': + const state: PblNgridColumnDefinitionSetState['table'] = { cols: [] }; + runChildChunkForDataMetaRows('s', state, ctx); + runChildChunksForRowDataColumns('s', state, ctx); + return state; + case 'header': + case 'footer': + const source = ctx.source[key]; + if (source && source.length > 0) { + const rows = []; + for (const row of source) { + const active = ctx.extApi.columnStore.metaColumnIds[key].find( r => !r.isGroup && r.rowDef.rowIndex === row.rowIndex ); + const r: PblNgridMetaRowSetState = {} as any; + ctx.runChildChunk('metaRow', r, row); + r.cols = runChildChunksForRowMetaColumns('metaColumn', ctx, row.cols); + rows.push(r); + } + return rows; } - return rows; - } - break; - case 'headerGroup': - const headerGroupSource = ctx.source.headerGroup; - if (headerGroupSource && headerGroupSource.length > 0) { - const rows = []; - for (const row of headerGroupSource) { - const active = ctx.extApi.columnStore.metaColumnIds.header.find( r => !r.isGroup && r.rowDef.rowIndex === row.rowIndex ); - const r: PblNgridMetaRowSetState = {} as any; - ctx.runChildChunk('metaGroupRow', r, row); - r.cols = runChildChunksForRowMetaColumns('metaColumn', ctx, row.cols); - rows.push(r); + break; + case 'headerGroup': + const headerGroupSource = ctx.source.headerGroup; + if (headerGroupSource && headerGroupSource.length > 0) { + const rows = []; + for (const row of headerGroupSource) { + const active = ctx.extApi.columnStore.metaColumnIds.header.find( r => !r.isGroup && r.rowDef.rowIndex === row.rowIndex ); + const r: PblNgridMetaRowSetState = {} as any; + ctx.runChildChunk('metaGroupRow', r, row); + r.cols = runChildChunksForRowMetaColumns('metaColumn', ctx, row.cols); + rows.push(r); + } + return rows; } - return rows; - } - break; - } - }) - .deserialize( (key, stateValue, ctx) => { - switch (key) { - case 'table': - const state = stateValue as PblNgridColumnDefinitionSetState['table']; - runChildChunkForDataMetaRows('d', state, ctx); - runChildChunksForRowDataColumns('d', state, ctx); - break; - case 'header': - case 'footer': - const source = ctx.source[key]; - const metaRowsState = stateValue as PblNgridColumnDefinitionSetState['header']; - if (metaRowsState && metaRowsState.length > 0) { - for (const rowState of metaRowsState) { - const row = source.find( r => r.rowIndex === rowState.rowIndex ); - if (row) { - const active = ctx.extApi.columnStore.metaColumnIds[key].find( r => !r.isGroup && r.rowDef.rowIndex === rowState.rowIndex ); - ctx.runChildChunk('metaRow', rowState, row); - for (const colState of rowState.cols) { - const col = row.cols.find( r => r.id === colState.id); - if (col) { - const activeColStore = ctx.extApi.columnStore.find(colState.id); - const activeCol = activeColStore && activeColStore.header; - ctx.runChildChunk('metaColumn', colState, col); + break; + } + }) + .deserialize( (key, stateValue, ctx) => { + switch (key) { + case 'table': + const state = stateValue as PblNgridColumnDefinitionSetState['table']; + runChildChunkForDataMetaRows('d', state, ctx); + runChildChunksForRowDataColumns('d', state, ctx); + break; + case 'header': + case 'footer': + const source = ctx.source[key]; + const metaRowsState = stateValue as PblNgridColumnDefinitionSetState['header']; + if (metaRowsState && metaRowsState.length > 0) { + for (const rowState of metaRowsState) { + const row = source.find( r => r.rowIndex === rowState.rowIndex ); + if (row) { + const active = ctx.extApi.columnStore.metaColumnIds[key].find( r => !r.isGroup && r.rowDef.rowIndex === rowState.rowIndex ); + ctx.runChildChunk('metaRow', rowState, row); + for (const colState of rowState.cols) { + const col = row.cols.find( r => r.id === colState.id); + if (col) { + const activeColStore = ctx.extApi.columnStore.find(colState.id); + const activeCol = activeColStore && activeColStore.header; + ctx.runChildChunk('metaColumn', colState, col); + } } } } } - } - break; - case 'headerGroup': - break; - } - }) - .register(); + break; + case 'headerGroup': + break; + } + }) + .register(); -import './children'; + registerColumnDefChildHandlers(); +} export { PblNgridMetaColumnState, diff --git a/libs/ngrid/state/src/lib/core/built-in-handlers/column-order/index.ts b/libs/ngrid/state/src/lib/core/built-in-handlers/column-order/index.ts index 1fada57c9..c89552ee3 100644 --- a/libs/ngrid/state/src/lib/core/built-in-handlers/column-order/index.ts +++ b/libs/ngrid/state/src/lib/core/built-in-handlers/column-order/index.ts @@ -3,45 +3,47 @@ import { createStateChunkHandler } from '../../handling'; import { stateVisor } from '../../state-visor'; import { PblNgridStateLoadOptions } from '../../models/index'; -stateVisor.registerRootChunkSection( - 'columnOrder', - { - sourceMatcher: ctx => ctx.grid.columnApi, - stateMatcher: state => { - if (!state.columnOrder) { - state.columnOrder = []; +export function registerColumnOrderHandlers() { + stateVisor.registerRootChunkSection( + 'columnOrder', + { + sourceMatcher: ctx => ctx.grid.columnApi, + stateMatcher: state => { + if (!state.columnOrder) { + state.columnOrder = []; + } + return state; } - return state; } - } -); + ); -createStateChunkHandler('columnOrder') - .handleKeys('columnOrder') - .serialize( (key, ctx) => ctx.source.visibleColumnIds.slice() ) - .deserialize( (key, columnOrder, ctx) => { - const { extApi, grid } = ctx; - let lastMove: [PblColumn, PblColumn]; + createStateChunkHandler('columnOrder') + .handleKeys('columnOrder') + .serialize( (key, ctx) => ctx.source.visibleColumnIds.slice() ) + .deserialize( (key, columnOrder, ctx) => { + const { extApi, grid } = ctx; + let lastMove: [PblColumn, PblColumn]; - const { visibleColumnIds } = grid.columnApi; - if (columnOrder && columnOrder.length === visibleColumnIds.length) { - for (let i = 0, len = columnOrder.length; i < len; i++) { - if (columnOrder[i] !== visibleColumnIds[i]) { - const column = grid.columnApi.findColumn(columnOrder[i]); - if (!column) { - return; + const { visibleColumnIds } = grid.columnApi; + if (columnOrder && columnOrder.length === visibleColumnIds.length) { + for (let i = 0, len = columnOrder.length; i < len; i++) { + if (columnOrder[i] !== visibleColumnIds[i]) { + const column = grid.columnApi.findColumn(columnOrder[i]); + if (!column) { + return; + } + const anchor = grid.columnApi.findColumn(visibleColumnIds[i]); + lastMove = [column, anchor]; + grid.columnApi.moveColumn(column, anchor, true); + extApi.columnStore.updateGroups(); } - const anchor = grid.columnApi.findColumn(visibleColumnIds[i]); - lastMove = [column, anchor]; - grid.columnApi.moveColumn(column, anchor, true); - extApi.columnStore.updateGroups(); } } - } - // With this revert/redo of the last move we just trigger a redraw. - if (lastMove) { - grid.columnApi.moveColumn(lastMove[1], lastMove[0], true); - grid.columnApi.moveColumn(lastMove[0], lastMove[1], (ctx.options as PblNgridStateLoadOptions).avoidRedraw); - } - }) - .register(); + // With this revert/redo of the last move we just trigger a redraw. + if (lastMove) { + grid.columnApi.moveColumn(lastMove[1], lastMove[0], true); + grid.columnApi.moveColumn(lastMove[0], lastMove[1], (ctx.options as PblNgridStateLoadOptions).avoidRedraw); + } + }) + .register(); + } diff --git a/libs/ngrid/state/src/lib/core/built-in-handlers/grid-primitives/index.ts b/libs/ngrid/state/src/lib/core/built-in-handlers/grid-primitives/index.ts index a93dabbc8..283970e9c 100644 --- a/libs/ngrid/state/src/lib/core/built-in-handlers/grid-primitives/index.ts +++ b/libs/ngrid/state/src/lib/core/built-in-handlers/grid-primitives/index.ts @@ -10,18 +10,20 @@ export interface PblNgridSurfaceState extends never > { } -stateVisor.registerRootChunkSection( - 'grid', - { - sourceMatcher: ctx => ctx.grid, - stateMatcher: state => state.grid || (state.grid = {} as any) - } -); +export function registerGridHandlers() { + stateVisor.registerRootChunkSection( + 'grid', + { + sourceMatcher: ctx => ctx.grid, + stateMatcher: state => state.grid || (state.grid = {} as any) + } + ); -createStateChunkHandler('grid') - .handleKeys('showHeader', 'showFooter', 'focusMode', 'identityProp', 'usePagination', 'hideColumns', 'fallbackMinHeight') - .serialize( (key, ctx) => ctx.source[key] ) - .deserialize( (key, stateValue, ctx) => { - ctx.source[key] = stateValue - }) - .register(); + createStateChunkHandler('grid') + .handleKeys('showHeader', 'showFooter', 'focusMode', 'identityProp', 'usePagination', 'hideColumns', 'fallbackMinHeight') + .serialize( (key, ctx) => ctx.source[key] ) + .deserialize( (key, stateValue, ctx) => { + ctx.source[key] = stateValue + }) + .register(); +} diff --git a/libs/ngrid/state/src/lib/core/built-in-handlers/index.ts b/libs/ngrid/state/src/lib/core/built-in-handlers/index.ts index a08661730..1bd54581d 100644 --- a/libs/ngrid/state/src/lib/core/built-in-handlers/index.ts +++ b/libs/ngrid/state/src/lib/core/built-in-handlers/index.ts @@ -13,13 +13,8 @@ import { PblNgridGlobalState, StateChunkItem } from '../models/index'; import * as C from './column-def/index'; import { PblNgridSurfaceState } from './grid-primitives/index'; -import './grid-primitives/index'; export * from './grid-primitives/index'; - -import './column-def/index'; export * from './column-def/index'; - -import './column-order/index'; export * from './column-order/index'; export interface PblNgridBuiltInGlobalState { diff --git a/libs/ngrid/state/src/lib/core/index.ts b/libs/ngrid/state/src/lib/core/index.ts index 21ae93282..ffb4b5ae7 100644 --- a/libs/ngrid/state/src/lib/core/index.ts +++ b/libs/ngrid/state/src/lib/core/index.ts @@ -1,5 +1,3 @@ -import './built-in-handlers/index'; - export { StateVisor, stateVisor } from './state-visor'; export { PblNgridLocalStoragePersistAdapter } from './persistance/index'; diff --git a/libs/ngrid/state/src/lib/state-plugin.ts b/libs/ngrid/state/src/lib/state-plugin.ts index d24502f05..b0618ef50 100644 --- a/libs/ngrid/state/src/lib/state-plugin.ts +++ b/libs/ngrid/state/src/lib/state-plugin.ts @@ -1,10 +1,12 @@ -import { Subject, Observable } from 'rxjs'; +import { Subject, Observable, from } from 'rxjs'; import { map, mapTo, filter, take, skip, debounceTime } from 'rxjs/operators'; import { Directive, OnDestroy, Injector, Input } from '@angular/core'; import { UnRx } from '@pebula/utils'; import { PblNgridComponent, PblNgridPluginController, TablePlugin } from '@pebula/ngrid'; import { hasState, saveState, loadState, PblNgridStateLoadOptions, PblNgridStateSaveOptions } from './core/index'; +import { registerBuiltInHandlers } from './core/built-in-handlers/_register'; + import { userSessionPref } from './presets'; declare module '@pebula/ngrid/lib/table/services/config' { @@ -40,7 +42,7 @@ interface InternalStatePluginEvents { export const PLUGIN_KEY: 'state' = 'state'; -@TablePlugin({ id: PLUGIN_KEY, factory: 'create' }) +@TablePlugin({ id: PLUGIN_KEY, factory: 'create', runOnce: registerBuiltInHandlers }) @UnRx() export class PblNgridStatePlugin { diff --git a/package.json b/package.json index 595ce1deb..91b6058b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pebula", - "version": "1.0.0-alpha.21", + "version": "1.0.0-alpha.22", "license": "MIT", "scripts": { "ng": "ng",