1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | import { ReferenceConstructor } from '../exp/Reference';
|
18 | import { Node } from './snap/Node';
|
19 | import { SyncPoint } from './SyncPoint';
|
20 | import { ImmutableTree } from './util/ImmutableTree';
|
21 | import { Path } from './util/Path';
|
22 | import { Event } from './view/Event';
|
23 | import { EventRegistration, QueryContext } from './view/EventRegistration';
|
24 | import { WriteTree } from './WriteTree';
|
25 | export declare function syncTreeSetReferenceConstructor(val: ReferenceConstructor): void;
|
26 | export interface ListenProvider {
|
27 | startListening(query: QueryContext, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event[]): Event[];
|
28 | stopListening(a: QueryContext, b: number | null): void;
|
29 | }
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | export declare class SyncTree {
|
52 | listenProvider_: ListenProvider;
|
53 | |
54 |
|
55 |
|
56 | syncPointTree_: ImmutableTree<SyncPoint>;
|
57 | |
58 |
|
59 |
|
60 | pendingWriteTree_: WriteTree;
|
61 | readonly tagToQueryMap: Map<number, string>;
|
62 | readonly queryToTagMap: Map<string, number>;
|
63 | |
64 |
|
65 |
|
66 |
|
67 | constructor(listenProvider_: ListenProvider);
|
68 | }
|
69 | /**
|
70 | * Apply the data changes for a user-generated set() or transaction() call.
|
71 | *
|
72 | * @returns Events to raise.
|
73 | */
|
74 | export declare function syncTreeApplyUserOverwrite(syncTree: SyncTree, path: Path, newData: Node, writeId: number, visible?: boolean): Event[];
|
75 | /**
|
76 | * Apply the data from a user-generated update() call
|
77 | *
|
78 | * @returns Events to raise.
|
79 | */
|
80 | export declare function syncTreeApplyUserMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
81 | [k: string]: Node;
|
82 | }, writeId: number): Event[];
|
83 | /**
|
84 | * Acknowledge a pending user write that was previously registered with applyUserOverwrite() or applyUserMerge().
|
85 | *
|
86 | * @param revert - True if the given write failed and needs to be reverted
|
87 | * @returns Events to raise.
|
88 | */
|
89 | export declare function syncTreeAckUserWrite(syncTree: SyncTree, writeId: number, revert?: boolean): Event[];
|
90 | /**
|
91 | * Apply new server data for the specified path..
|
92 | *
|
93 | * @returns Events to raise.
|
94 | */
|
95 | export declare function syncTreeApplyServerOverwrite(syncTree: SyncTree, path: Path, newData: Node): Event[];
|
96 | /**
|
97 | * Apply new server data to be merged in at the specified path.
|
98 | *
|
99 | * @returns Events to raise.
|
100 | */
|
101 | export declare function syncTreeApplyServerMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
102 | [k: string]: Node;
|
103 | }): Event[];
|
104 | /**
|
105 | * Apply a listen complete for a query
|
106 | *
|
107 | * @returns Events to raise.
|
108 | */
|
109 | export declare function syncTreeApplyListenComplete(syncTree: SyncTree, path: Path): Event[];
|
110 | /**
|
111 | * Apply a listen complete for a tagged query
|
112 | *
|
113 | * @returns Events to raise.
|
114 | */
|
115 | export declare function syncTreeApplyTaggedListenComplete(syncTree: SyncTree, path: Path, tag: number): Event[];
|
116 | /**
|
117 | * Remove event callback(s).
|
118 | *
|
119 | * If query is the default query, we'll check all queries for the specified eventRegistration.
|
120 | * If eventRegistration is null, we'll remove all callbacks for the specified query/queries.
|
121 | *
|
122 | * @param eventRegistration - If null, all callbacks are removed.
|
123 | * @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
|
124 | * @returns Cancel events, if cancelError was provided.
|
125 | */
|
126 | export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error): Event[];
|
127 | /**
|
128 | * Apply new server data for the specified tagged query.
|
129 | *
|
130 | * @returns Events to raise.
|
131 | */
|
132 | export declare function syncTreeApplyTaggedQueryOverwrite(syncTree: SyncTree, path: Path, snap: Node, tag: number): Event[];
|
133 | /**
|
134 | * Apply server data to be merged in for the specified tagged query.
|
135 | *
|
136 | * @returns Events to raise.
|
137 | */
|
138 | export declare function syncTreeApplyTaggedQueryMerge(syncTree: SyncTree, path: Path, changedChildren: {
|
139 | [k: string]: Node;
|
140 | }, tag: number): Event[];
|
141 | /**
|
142 | * Add an event callback for the specified query.
|
143 | *
|
144 | * @returns Events to raise.
|
145 | */
|
146 | export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration): Event[];
|
147 | /**
|
148 | * Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
|
149 | * listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
|
150 | * have a listener above, and atomic operations would correctly show a jitter of <increment value> ->
|
151 | * <incremented total> as the write is applied locally and then acknowledged at the server.
|
152 | *
|
153 | * Note: this method will *include* hidden writes from transaction with applyLocally set to false.
|
154 | *
|
155 | * @param path - The path to the data we want
|
156 | * @param writeIdsToExclude - A specific set to be excluded
|
157 | */
|
158 | export declare function syncTreeCalcCompleteEventCache(syncTree: SyncTree, path: Path, writeIdsToExclude?: number[]): Node;
|
159 | export declare function syncTreeGetServerValue(syncTree: SyncTree, query: QueryContext): Node | null;
|