mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-11-15 12:40:12 +00:00
refactor: organise source files by ownership
Separate host-independent helpers under common/core and colocate feature support code with its owners. Update imports, tests, and source-layout guidance while preserving runtime behaviour.
This commit is contained in:
1 parent
9a0941647b
commit
73adfe3a74
115 files changed
+115
-103
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { createOwnedResource } from "octagonal-wheels/resource";
|
||||
import type { RemoteDBSettings } from "@vrtmrz/livesync-commonlib/compat/common/types";
|
||||
|
||||
/**
|
||||
* Closeable surface of a concrete Replicator owned by one private resource.
|
||||
*
|
||||
* It deliberately exposes no active-provider controls: the resource may use
|
||||
* the helper for one bounded operation, then must dispose it without
|
||||
* publishing or replacing the active Replicator.
|
||||
*/
|
||||
export interface ResourceReplicator {
|
||||
closeReplication(): void | Promise<void>;
|
||||
}
|
||||
|
||||
/** Create one idempotent asynchronous disposer for a private Replicator. */
|
||||
export function createReplicatorDisposer(replicator: ResourceReplicator): () => Promise<void> {
|
||||
const resource = createOwnedResource(replicator, (owned) => Promise.resolve().then(() => owned.closeReplication()));
|
||||
return () => Promise.resolve(resource.dispose());
|
||||
}
|
||||
|
||||
/** Fence a finite resource from later edits to its source settings object. */
|
||||
export function snapshotRemoteSettings(setting: RemoteDBSettings): RemoteDBSettings {
|
||||
return { ...setting };
|
||||
}
|
||||
Reference in new issue
Block a user