diff options
author | bob <bcz@cs.brown.edu> | 2019-02-07 16:07:29 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2019-02-07 16:07:29 -0500 |
commit | f2f9261c6469ed330ff9395fb97e15ca53c891f2 (patch) | |
tree | c56144676ce79db70d14d79e414f6b9cf53cdf95 | |
parent | ccee60f591cdb00b04c4e5db0483420b9db7b7c8 (diff) |
final cleanup pass.
-rw-r--r-- | src/Server.tsx | 8 | ||||
-rw-r--r-- | src/SocketStub.tsx | 2 | ||||
-rw-r--r-- | src/fields/Document.ts | 2 | ||||
-rw-r--r-- | src/fields/Field.ts | 1 |
4 files changed, 6 insertions, 7 deletions
diff --git a/src/Server.tsx b/src/Server.tsx index 83f0d0f43..7eeec25e1 100644 --- a/src/Server.tsx +++ b/src/Server.tsx @@ -1,11 +1,11 @@ -import { Field, FieldWaiting, FIELD_ID, DOC_ID, FIELD_WAITING } from "./fields/Field" +import { Field, FieldWaiting, FIELD_ID, FIELD_WAITING } from "./fields/Field" import { Key, KeyStore } from "./fields/Key" import { ObservableMap, action } from "mobx"; import { Document } from "./fields/Document" import { SocketStub } from "./SocketStub"; export class Server { - private static ClientFieldsCached: ObservableMap<DOC_ID, Field | FIELD_WAITING> = new ObservableMap(); + private static ClientFieldsCached: ObservableMap<FIELD_ID, Field | FIELD_WAITING> = new ObservableMap(); // Retrieves the cached value of the field and sends a request to the server for the real value (if it's not cached). // Call this is from within a reaction and test whether the return value is FieldWaiting. @@ -25,14 +25,14 @@ export class Server { static times = 0; // hack for testing public static GetDocumentField(doc: Document, key: Key) { - var timeoutHack: number = key == KeyStore.Data ? (this.times++ == 0 ? 5000 : 1000) : key == KeyStore.X ? 2500 : 500; + var hackTimeout: number = key == KeyStore.Data ? (this.times++ == 0 ? 5000 : 1000) : key == KeyStore.X ? 2500 : 500; var field = this.GetField(doc._proxies.get(key), action((fieldfromserver: Field) => { doc._proxies.delete(key); doc.fields.set(key, this.cacheField(fieldfromserver)); }) - , timeoutHack); + , hackTimeout); if (field != FieldWaiting) { doc._proxies.delete(key); // perhaps another document inquired the same field } diff --git a/src/SocketStub.tsx b/src/SocketStub.tsx index 49a847d34..f9d48c067 100644 --- a/src/SocketStub.tsx +++ b/src/SocketStub.tsx @@ -1,4 +1,4 @@ -import { Field, FieldWaiting, FIELD_ID, DOC_ID, FIELD_WAITING } from "./fields/Field" +import { Field, FIELD_ID } from "./fields/Field" import { Key, KeyStore } from "./fields/Key" import { ObservableMap, action } from "mobx"; import { Document } from "./fields/Document" diff --git a/src/fields/Document.ts b/src/fields/Document.ts index 3d74c047c..cc81ff4a7 100644 --- a/src/fields/Document.ts +++ b/src/fields/Document.ts @@ -1,4 +1,4 @@ -import { Field, Cast, Opt, FieldWaiting, FIELD_ID, DOC_ID } from "./Field" +import { Field, Cast, Opt, FieldWaiting, FIELD_ID } from "./Field" import { Key, KeyStore } from "./Key" import { NumberField } from "./NumberField"; import { ObservableMap, computed, action, observable } from "mobx"; diff --git a/src/fields/Field.ts b/src/fields/Field.ts index 9880116c0..3c1e976d4 100644 --- a/src/fields/Field.ts +++ b/src/fields/Field.ts @@ -13,7 +13,6 @@ export function Cast<T extends Field>(field: Opt<Field>, ctor: { new(): T }): Op export let FieldWaiting: FIELD_WAITING = "<Waiting>"; export type FIELD_WAITING = "<Waiting>"; export type FIELD_ID = string | undefined; -export type DOC_ID = FIELD_ID; export type Opt<T> = T | undefined | FIELD_WAITING; export abstract class Field { |