Fix emitters
This commit is contained in:
parent
579a0f1db2
commit
55cda4d4ae
12 changed files with 32 additions and 12 deletions
1
dist/src/client.d.ts
vendored
1
dist/src/client.d.ts
vendored
|
@ -65,6 +65,7 @@ export declare class Client extends Client_base {
|
|||
lists: Lists;
|
||||
rooms: Rooms;
|
||||
constructor(config: ClientConfig);
|
||||
private setState;
|
||||
start(): void;
|
||||
stop(): void;
|
||||
}
|
||||
|
|
10
dist/src/client.js
vendored
10
dist/src/client.js
vendored
|
@ -94,17 +94,21 @@ export class Client extends EventEmitter {
|
|||
});
|
||||
this.conn = new Connection(this);
|
||||
}
|
||||
setState(state) {
|
||||
this.state = state;
|
||||
this.emit("state", state);
|
||||
}
|
||||
// Start receiving events from /sync.
|
||||
// WARN: if you lose the reference to Client, the poller will leak
|
||||
start() {
|
||||
this.state = { state: "sync" };
|
||||
this.setState({ state: "sync" });
|
||||
(async () => {
|
||||
while (this.state.state === "sync") {
|
||||
try {
|
||||
await this.conn.sync();
|
||||
}
|
||||
catch (err) {
|
||||
this.state = { state: "error", reason: err };
|
||||
this.setState({ state: "error", reason: err });
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
@ -113,7 +117,7 @@ export class Client extends EventEmitter {
|
|||
stop() {
|
||||
this.conn.abort();
|
||||
this.conn = new Connection(this);
|
||||
this.state = { state: "stop" };
|
||||
this.setState({ state: "stop" });
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=client.js.map
|
2
dist/src/client.js.map
vendored
2
dist/src/client.js.map
vendored
|
@ -1 +1 @@
|
|||
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqDlC,MAAM,KAAM,SAAQ,GAAiB;IACnC,YAAmB,MAAc;QAC/B,KAAK,E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AAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,EAAE,CAAA;IACN,CAAC;IAED,oCAAoC;IACpC,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;CACF"}
|
4
dist/src/index.d.ts
vendored
4
dist/src/index.d.ts
vendored
|
@ -1 +1,5 @@
|
|||
export { Client } from "./client.js";
|
||||
export type { Event, StateEvent } from "./event.js";
|
||||
export type { Room } from "./room.js";
|
||||
export type { Thread } from "./thread.js";
|
||||
export type { Timeline } from "./timeline.js";
|
||||
|
|
1
dist/src/sync.js
vendored
1
dist/src/sync.js
vendored
|
@ -91,6 +91,7 @@ export class Connection {
|
|||
throw new Error("unimplemented");
|
||||
}
|
||||
}
|
||||
this.client.emit("list", listId, list);
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
|
2
dist/src/sync.js.map
vendored
2
dist/src/sync.js.map
vendored
|
@ -1 +1 @@
|
|||
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/sync.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,6DAA6D;AAG7D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,OAAO,UAAU;IAOrB,YAAoB,MAAc;QAAtB;;;;mBAAQ,MAAM;WAAQ;QAN1B;;;;mBAAS,MAAM,EAAE;WAAC;QAClB;;;;mBAAa,IAAI,eAAe,EAAE;WAAC;QACnC;;;;mBAAc,GAAG;WAAC;QAClB;;;;;WAA0B;QAC1B;;;;mBAAqB,E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,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,eAAe,CAAC,IAAY;QAC1B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,OAAO;QAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,YAA8B;QAC1D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC;QACxC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,eAAe,CAAC,MAAc;QAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,MAAe;QACnB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;CACF"}
|
3
dist/src/timeline.d.ts
vendored
3
dist/src/timeline.d.ts
vendored
|
@ -2,7 +2,7 @@ import { EventId } from "./api.js";
|
|||
import { Room } from "./room.js";
|
||||
import { Event } from "./event.js";
|
||||
import { Thread } from "./thread.js";
|
||||
interface Timeline {
|
||||
export interface Timeline {
|
||||
isLive: boolean;
|
||||
events: Array<Event>;
|
||||
}
|
||||
|
@ -30,4 +30,3 @@ export declare class TimelineSet {
|
|||
forEvent(eventId: EventId): Promise<RoomTimeline>;
|
||||
_appendEvents(events: Array<Event>): void;
|
||||
}
|
||||
export {};
|
||||
|
|
2
dist/tsconfig.tsbuildinfo
vendored
2
dist/tsconfig.tsbuildinfo
vendored
File diff suppressed because one or more lines are too long
|
@ -116,17 +116,22 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter<C
|
|||
this.conn = new Connection(this);
|
||||
}
|
||||
|
||||
private setState(state: ClientState) {
|
||||
this.state = state;
|
||||
this.emit("state", state);
|
||||
}
|
||||
|
||||
// Start receiving events from /sync.
|
||||
// WARN: if you lose the reference to Client, the poller will leak
|
||||
start() {
|
||||
this.state = { state: "sync" };
|
||||
this.setState({ state: "sync" });
|
||||
|
||||
(async () => {
|
||||
while (this.state.state === "sync") {
|
||||
try {
|
||||
await this.conn.sync();
|
||||
} catch (err) {
|
||||
this.state = { state: "error", reason: err };
|
||||
this.setState({ state: "error", reason: err });
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
@ -136,6 +141,6 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter<C
|
|||
stop() {
|
||||
this.conn.abort();
|
||||
this.conn = new Connection(this);
|
||||
this.state = { state: "stop" };
|
||||
this.setState({ state: "stop" });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,5 @@
|
|||
export { Client } from "./client.js";
|
||||
export type { Event, StateEvent } from "./event.js";
|
||||
export type { Room } from "./room.js";
|
||||
export type { Thread } from "./thread.js";
|
||||
export type { Timeline } from "./timeline.js";
|
||||
|
|
|
@ -67,6 +67,8 @@ export class Connection {
|
|||
throw new Error("unimplemented");
|
||||
}
|
||||
}
|
||||
|
||||
this.client.emit("list", listId, list);
|
||||
}
|
||||
|
||||
return json;
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Room } from "./room.js";
|
|||
import { Event } from "./event.js";
|
||||
import { Thread } from "./thread.js";
|
||||
|
||||
interface Timeline {
|
||||
export interface Timeline {
|
||||
isLive: boolean,
|
||||
events: Array<Event>,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue