v0.19: Batch Controller.set(), Faster TypeScript
v0.19 lets a Manager write a whole batch of streamed rows in one store update, type-checks endpoint code about 2x faster, and fixes a round of TypeScript and Vue issues.
Batch Controller.set() writes a whole stream of rows, like price tickers from a websocket, in one
store update with ctrl.set([Ticker], rows). That is up to 95x faster than one set() per row.
Try both buttons below. This browser check starts from an empty store and times Promise.all of 500 set()
calls against one batch set(). Both paths are one React commit, and each writes 500 new prices.
import { useController } from '@data-client/react'; import { Ticker, newPrices } from './Ticker'; import { useTimed, Timing } from './Timing'; import PriceHeader from './PriceHeader'; function PriceStream() { const ctrl = useController(); const [perRowMs, perRow] = useTimed(newPrices, rows => Promise.all( rows.map(row => ctrl.set(Ticker, { product_id: row.product_id }, row)), ), ); const [batchMs, batch] = useTimed(newPrices, rows => ctrl.set([Ticker], rows), ); return ( <> <PriceHeader /> <dl className="stats"> <Timing label="500 set() calls" ms={perRowMs} /> <Timing label="1 batch set()" ms={batchMs} /> </dl> <div className="buttonGroup"> <button onClick={perRow}>set() per row</button> <button onClick={batch}>batch set()</button> </div> </> ); } render(<PriceStream />);
Faster TypeScript: editors and tsc check RestEndpoint and
resource() code about 2x faster with 40% less memory, and still report every error they reported
before.
More in v0.19:
- Performance: faster Redux DevTools, shorter React Native GC pauses and smaller split bundles
- Client: delete one entity with set(), unawaited reads need no
.catch(),<Activity>above DataProvider, and loading and error fixes - Platforms: React Native 0.87 and Babel 8
- Vue: garbage collection by default, stale-while-revalidate and getter arguments
- Collections: lists of items in every update, and each item shown once
- Validation: typed
set()values,process()params and optimistic responses; testing and warning fixes
- For all users
- The Next.js Pages Router is not supported; use the App Router (#4648)
- TypeScript 4.0 or later is required - the TypeScript 3.x declarations are removed (#4151)
managersis a function that creates each store's Managers;npx @data-client/codemods v0.19 src/converts arrays (#4601)- Controller.fetchIfStale() always returns a Promise, so prefetches need no
.catch()(#4657) __DC_CONTROLLERS__is now__DC__for debugging scripts (#4435)
- For custom Manager authors
- Managers must define
middleware-getMiddleware()is removed (#4378, #4382) - Manager
cleanup()no longer means the store is gone - start timers and connections ininit(), andNetworkManager.cleanupDateis removed (#4593)
- Managers must define
- For test authors
Get ready for future releases:
- Type
argsasreadonlyinEntity.pk()overrides - Use
DataClientPlugininstead of VuecreateDataClient() - Replace
waitForNextUpdate()in Vue tests
Adopt new features: npx @data-client/codemods v0.19 src/ --improvements=only batches set() loops and drops workarounds 0.19 makes unnecessary
