Invent an AsyncStore and use it for room lists

This is to get around the problem of a slow dispatch loop. Instead of slowing the whole app down to deal with room lists, we'll just raise events to say we're ready.

Based upon the EventEmitter class.
This commit is contained in:
Travis Ralston 2020-04-27 15:25:04 -06:00
parent 08419d195e
commit 861268d39f
7 changed files with 144 additions and 35 deletions

View file

@ -21,7 +21,7 @@ import { _t } from "../../../languageHandler";
import { Layout } from '../../../resizer/distributors/roomsublist2';
import { RovingTabIndexProvider } from "../../../accessibility/RovingTabIndex";
import { ResizeNotifier } from "../../../utils/ResizeNotifier";
import RoomListStore from "../../../stores/room-list/RoomListStore2";
import RoomListStore, { LISTS_UPDATE_EVENT } from "../../../stores/room-list/RoomListStore2";
interface IProps {
onKeyDown: (ev: React.KeyboardEvent) => void;
@ -56,8 +56,8 @@ export default class RoomList2 extends React.Component<IProps, IState> {
}
public componentDidMount(): void {
RoomListStore.instance.addListener(() => {
console.log(RoomListStore.instance.orderedLists);
RoomListStore.instance.on(LISTS_UPDATE_EVENT, (store) => {
console.log("new lists", store.orderedLists);
});
}