Enterprise optimizations for SignalTree reactive JSON. Diff-based updates, bulk operations, and advanced change tracking for large-scale applications.
npm install @signaltree/enterpriseEnterprise-grade optimizations for SignalTree. Designed for large-scale applications with 500+ signals and high-frequency bulk updates.
- Diff-based updates - Only update signals that actually changed
- Bulk operation optimization - 2-5x faster for large state updates
- Advanced change tracking - Detailed statistics and monitoring
- Path indexing - Optimized signal lookup for large trees
- Lazy initialization - Zero overhead until first use
``bash`
npm install @signaltree/core @signaltree/enterprise
`typescript
import { signalTree } from '@signaltree/core';
import { enterprise } from '@signaltree/enterprise';
const tree = signalTree(largeState).with(enterprise());
// Use optimized bulk updates
const result = tree.updateOptimized(newData, {
ignoreArrayOrder: true,
maxDepth: 10,
});
console.log(result.stats);
// { totalChanges: 45, adds: 10, updates: 30, deletes: 5 }
`
- You have 500+ signals in your state tree
- Bulk updates happen at high frequency (60Hz+)
- You need real-time dashboards or data feeds
- You're building enterprise-scale applications
- You need detailed update monitoring and statistics
- Small to medium apps (<100 signals)
- Infrequent state updates
- Startup/prototype projects
- Bundle size is critical (adds +2.4KB gzipped)
Enhancer that adds enterprise optimizations to a SignalTree.
`typescript
import { signalTree } from '@signaltree/core';
import { enterprise } from '@signaltree/enterprise';
const tree = signalTree(initialState).with(enterprise());
`
Performs optimized bulk updates using diff-based change detection.
Parameters:
- updates: Partial - The new state valuesoptions?: UpdateOptions
- - Configuration options
Options:
`typescript`
{
maxDepth?: number; // Maximum depth to traverse (default: 100)
ignoreArrayOrder?: boolean; // Ignore array element order (default: false)
equalityFn?: (a, b) => boolean; // Custom equality function
autoBatch?: boolean; // Automatically batch updates (default: true)
batchSize?: number; // Patches per batch (default: 10)
}
Returns:
`typescript`
{
changed: boolean; // Whether any changes were made
stats: {
totalChanges: number; // Total number of changes
adds: number; // New properties added
updates: number; // Properties updated
deletes: number; // Properties deleted
}
}
Get the PathIndex for debugging/monitoring. Returns null if updateOptimized hasn't been called yet (lazy initialization).
`typescript`
const index = tree.getPathIndex();
if (index) {
console.log('Path index active');
}
`typescript
import { signalTree } from '@signaltree/core';
import { enterprise } from '@signaltree/enterprise';
interface DashboardState {
metrics: Record
alerts: Alert[];
users: User[];
// ... hundreds more properties
}
const dashboard = signalTree
// High-frequency updates from WebSocket
socket.on('metrics', (newMetrics) => {
const result = dashboard.updateOptimized({ metrics: newMetrics }, { ignoreArrayOrder: true });
console.log(Updated ${result.stats.updates} metrics);`
});
`typescript
import { signalTree } from '@signaltree/core';
import { enterprise } from '@signaltree/enterprise';
const grid = signalTree({
rows: [] as GridRow[],
columns: [] as GridColumn[],
filters: {} as FilterState,
selection: new Set
}).with(enterprise());
// Bulk update from API
async function loadData() {
const data = await fetchGridData();
const result = grid.updateOptimized(data, {
maxDepth: 5,
autoBatch: true,
});
console.log(Loaded ${result.stats.adds} rows in bulk);`
}
`typescript
const tree = signalTree(complexState).with(enterprise());
tree.updateOptimized(newState, {
equalityFn: (a, b) => {
// Custom deep equality for specific object types
if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime();
}
return a === b;
},
});
`
Bundle Size:
- Adds +2.4KB gzipped to your bundle
- Zero overhead until first updateOptimized()` call (lazy initialization)
Performance Gains:
- 2-5x faster for bulk updates on large state trees
- Scales efficiently with tree depth and complexity
- Minimal memory overhead with path indexing
Business Source License 1.1 (BSL-1.1) - See LICENSE for details.
Converts to MIT license on the Change Date specified in the license.
- @signaltree/core - Core SignalTree functionality
- @signaltree/ng-forms - Angular forms integration
- @signaltree/callable-syntax - Callable syntax transform