[CORL-666] Viewer Events (#2681)

* feat: viewer event system

* feat: more events

* feat: MORE events

* fix: tests

* fix: rte focus events

* chore: add comments

* fix: remove listening to events

* chore: update RTE

* fix: tests

* feature: generate event docs

* fix: remove obsolete line in docs

* chore: improve docs

* chore: improve formatting

* feature: protect events.md from getting out of sync

* chore: small improvements

* fix: removing redundant lambda
This commit is contained in:
Vinh
2019-11-08 17:17:01 +00:00
committed by Wyatt Johnson
parent ce4a3408fc
commit 18346d1683
99 changed files with 3839 additions and 1330 deletions
@@ -1,6 +1,8 @@
import { commitLocalUpdate, Environment } from "relay-runtime";
import { CoralContext } from "coral-framework/lib/bootstrap";
import { createMutationContainer, LOCAL_ID } from "coral-framework/lib/relay";
import { SetMainTabEvent } from "coral-stream/events";
export interface SetActiveTabInput {
tab: "COMMENTS" | "PROFILE" | "%future added value";
@@ -10,11 +12,15 @@ export type SetActiveTabMutation = (input: SetActiveTabInput) => Promise<void>;
export async function commit(
environment: Environment,
input: SetActiveTabInput
input: SetActiveTabInput,
{ eventEmitter }: Pick<CoralContext, "eventEmitter">
) {
return commitLocalUpdate(environment, store => {
const record = store.get(LOCAL_ID)!;
record.setValue(input.tab, "activeTab");
if (record.getValue("activeTab") !== input.tab) {
SetMainTabEvent.emit(eventEmitter, { tab: input.tab });
record.setValue(input.tab, "activeTab");
}
});
}