namespace mod_model.rental { /** */ export type type_id = string; /** */ export enum enum_condition { prior, running, paused, } /** */ export type type_subject = { id : type_id; condition : enum_condition; bike_name : (null | string); }; /** */ export function initial ( id : type_id ) : type_subject { return { "id": id, "condition": enum_condition.prior, "bike_name": null, }; } /** */ export async function start ( model : lib_mvc.type_model, bike_name : string ) : Promise { model.state.condition = enum_condition.running; model.state.bike_name = bike_name; await lib_mvc.model_notify ( model, { "type": "start", "data": {"id": model.state.id} } ); } /** */ export async function pause ( model : lib_mvc.type_model ) : Promise { model.state.condition = enum_condition.paused; await lib_mvc.model_notify ( model, { "type": "pause", "data": {"id": model.state.id} } ); } /** */ export async function open ( model : lib_mvc.type_model ) : Promise { model.state.condition = enum_condition.running; await lib_mvc.model_notify ( model, { "type": "open", "data": {"id": model.state.id} } ); } /** */ export async function end ( model : lib_mvc.type_model ) : Promise { await lib_mvc.model_notify ( model, { "type": "end", "data": {"id": model.state.id} } ); } }