— configuration (factory, onError, onDisplace)
const displace = createDisplaceTransfer<string, SearchResult>({
factory: () => createAsyncConvertTransfer<string, SearchResult>({
operator: createAsyncMapOperator(async (query) => await searchApi(query)),
}),
});
displace.subscribe(result => render(result));
displace.push('hello'); // creates inner, pushes 'hello' into it
displace.push('world'); // displaces previous inner, creates new one
Creates a DisplaceTransfer — a transfer that creates a new inner async-pushable + subscribable transfer per input value, pushes the value into it via asyncPush(), and forwards its emissions to outer subscribers.
On each new push(), the previous inner subscription is unsubscribed and the previous inner transfer is destroyed — the new inner displaces the previous one. Only the latest inner transfer's emissions reach the outer subscribers.