##// END OF EJS Templates
Added priorities to render tasks, revisited rendering scheduler...
Added priorities to render tasks, revisited rendering scheduler nested `watch` and `watchFor` has a lower priority then they enclosing renditions

File last commit:

r146:af4f8424e83d v1.9.0 default
r146:af4f8424e83d v1.9.0 default
Show More
MainModel.ts
78 lines | 2.2 KiB | video/mp2t | TypeScriptLexer
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 import { id as mid } from "module";
import { BehaviorSubject, Observer, Unsubscribable } from "rxjs";
import { IDestroyable } from "@implab/core-amd/interfaces";
cin
added reduce() and next() methods to observable...
r116 import { Observable } from "@implab/djx/observable";
import { OrderedUpdate } from "@implab/djx/store";
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 import { Appointment, Member } from "./Appointment";
import { MainContext } from "./MainContext";
import { LocalDate } from "@js-joda/core";
import { error } from "../logging";
import { TraceSource } from "@implab/core-amd/log/TraceSource";
cin
added whenRendered() method to wait for pending oprations to complete
r118 import { whenRendered } from "@implab/djx/tsx/render";
cin
Working on WatchForRendition
r107
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 const trace = TraceSource.get(mid);
export interface State {
cin
added reduce() and next() methods to observable...
r116 appointments: Observable<OrderedUpdate<Appointment>>;
cin
Working on WatchForRendition
r107
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 dateTo: LocalDate;
cin
Working on WatchForRendition
r107
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 dateFrom: LocalDate;
title: string;
cin
Working on WatchForRendition
r107 }
export default class MainModel implements IDestroyable {
private readonly _state: BehaviorSubject<State>;
cin
corrected tear down logic handling in observables. Added support for observable query results
r110
private readonly _context = new MainContext();
constructor() {
this._state = new BehaviorSubject<State>({
dateTo: LocalDate.now(),
dateFrom: LocalDate.now().minusMonths(1),
appointments: this._context.queryAppointments(),
title: "Appointments"
});
cin
Working on WatchForRendition
r107 }
getState() {
return this._state.getValue();
}
subscribe(observer: Partial<Observer<State>>): Unsubscribable {
return this._state.subscribe(observer);
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 }
cin
Working on WatchForRendition
r107 protected dispatch(command: Partial<State>) {
const state = this.getState();
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 this._state.next({ ...state, ...command });
}
addMember(appointmentId: string, member: Member) {
this._context.addMember(appointmentId, member).catch(error(trace));
cin
Working on WatchForRendition
r107 }
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 addAppointment(title: string, startAt: Date, duration: number) {
cin
added whenRendered() method to wait for pending oprations to complete
r118 this._context.createAppointment(title,startAt, duration, [])
.then(() => {
trace.debug("addAppointment done");
return whenRendered();
})
.then(() => {
trace.debug("Render dome");
})
.catch(error(trace));
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 }
cin
Added priorities to render tasks, revisited rendering scheduler...
r146 removeAppointment(appointmentId: string) {
this._context.removeAppointment(appointmentId).catch(error(trace));
}
cin
added whenRendered() method to wait for pending oprations to complete
r118
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 load() {
cin
added whenRendered() method to wait for pending oprations to complete
r118 this._context.load().catch(error(trace));
cin
corrected tear down logic handling in observables. Added support for observable query results
r110 }
destroy() {
this._context.destroy();
}
cin
Working on WatchForRendition
r107 }