Refine subscription import and refresh flow
This commit is contained in:
@@ -40,27 +40,3 @@ export function createOperationRegistry(onChange = () => {}, now = () => new Dat
|
||||
|
||||
return { run, getSnapshot: () => operations };
|
||||
}
|
||||
|
||||
export function createLatestRequest() {
|
||||
let controller = null;
|
||||
|
||||
return {
|
||||
run(action) {
|
||||
controller?.abort();
|
||||
controller = new AbortController();
|
||||
const current = controller;
|
||||
return Promise.resolve()
|
||||
.then(() => action(current.signal))
|
||||
.then(
|
||||
(value) => current.signal.aborted ? undefined : value,
|
||||
(error) => {
|
||||
if (current.signal.aborted) return undefined;
|
||||
throw error;
|
||||
},
|
||||
);
|
||||
},
|
||||
cancel() {
|
||||
controller?.abort();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user