Skip to content

Commit 8c20d85

Browse files
Persisting mutation batch state in LocalStorage
1 parent 6ef0c69 commit 8c20d85

File tree

6 files changed

+602
-107
lines changed

6 files changed

+602
-107
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2018 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { BatchId } from '../core/types';
18+
import { FirestoreError } from '../util/error';
19+
20+
/**
21+
* Callback methods invoked by SharedClientState for notifications received
22+
* from Local Storage.
23+
*/
24+
export interface SharedClientDelegate {
25+
/**
26+
* Loads a pending batch from the persistence layer and updates all views.
27+
*/
28+
loadPendingBatch(batchId: BatchId): Promise<void>;
29+
30+
/**
31+
* Applies the result of a successful write of a mutation batch, updating all
32+
* views and notifying all subscribers.
33+
*/
34+
applySuccessfulWrite(batchId: BatchId): Promise<void>;
35+
36+
/**
37+
* Rejects a failed mutation batch, updating all views and notifying all
38+
* subscribers.
39+
*/
40+
rejectFailedWrite(batchId: BatchId, err: FirestoreError): Promise<void>;
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2018 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { BatchId } from '../core/types';
18+
import { FirestoreError } from '../util/error';
19+
20+
/**
21+
* Callback methods invoked by SharedClientState for notifications received
22+
* from Local Storage.
23+
*/
24+
export interface SharedClientDelegate {
25+
/**
26+
* Loads a pending batch from the persistence layer and updates all views.
27+
*/
28+
loadPendingBatch(batchId: BatchId): Promise<void>;
29+
30+
/**
31+
* Applies the result of a successful write of a mutation batch, updating all
32+
* views and notifying all subscribers.
33+
*/
34+
applySuccessfulWrite(batchId: BatchId): Promise<void>;
35+
36+
/**
37+
* Rejects a failed mutation batch, updating all views and notifying all
38+
* subscribers.
39+
*/
40+
rejectFailedWrite(batchId: BatchId, err: FirestoreError): Promise<void>;
41+
}

0 commit comments

Comments
 (0)