Skip to content

Commit

Permalink
Revert back to use Model over ChildModel types
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbeck committed Oct 25, 2023
1 parent 7414202 commit 1b4d936
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { EventEmitter } from 'events';
import { basename } from 'path';

import { type ChildModel } from 'racer';
import { type Model } from 'racer';
import * as util from 'racer/lib/util';

import components = require('./components');
Expand Down Expand Up @@ -37,7 +37,7 @@ interface AppOptions {
scriptHash?: string,
}

type OnRouteCallback<T = object> = (arg0: Page, arg1: Page, model: ChildModel<T>, params: PageParams, done?: () => void) => void;
type OnRouteCallback<T = object> = (arg0: Page, arg1: Page, model: Model<T>, params: PageParams, done?: () => void) => void;

type Routes = [string, string, any][];

Expand All @@ -52,7 +52,7 @@ export abstract class AppBase<T = object> extends EventEmitter {
proto: any;
views: Views;
tracksRoutes: Routes;
model: ChildModel<T>;
model: Model<T>;
page: PageBase;
protected _pendingComponentMap: Record<string, ComponentConstructor>;
protected _waitForAttach: boolean;
Expand Down
6 changes: 3 additions & 3 deletions src/Controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'events';

import { type ChildModel } from 'racer';
import { type Model } from 'racer';

import { type AppBase } from './App';
import { Dom } from './Dom';
Expand All @@ -10,10 +10,10 @@ export class Controller<T = object> extends EventEmitter {
dom: Dom;
app: AppBase;
page: PageBase;
model: ChildModel<T>;
model: Model<T>;
markerNode: Node;

constructor(app: AppBase, page: PageBase, model: ChildModel<T>) {
constructor(app: AppBase, page: PageBase, model: Model<T>) {
super();
this.dom = new Dom(this);
this.app = app;
Expand Down
10 changes: 5 additions & 5 deletions src/Page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ChildModel } from 'racer';
import { type Model } from 'racer';
import util = require('racer/lib/util');

import { type AppBase, type App } from './App';
Expand All @@ -22,14 +22,14 @@ const {
export abstract class PageBase<T = object> extends Controller<T> {
params: Readonly<PageParams>;
context: Context;
create: (model: ChildModel<T>, dom: any) => void;
init?: (model: ChildModel<T>) => void;
create: (model: Model<T>, dom: any) => void;
init?: (model: Model<T>) => void;
_components: Record<string, components.Component>
_eventModel: any;
_removeModelListeners: () => void = () => {};
page: PageBase;

constructor(app: AppBase, model: ChildModel<T>) {
constructor(app: AppBase, model: Model<T>) {
super(app, null, model);
this.params = null;
this._eventModel = null;
Expand Down Expand Up @@ -110,7 +110,7 @@ export abstract class PageBase<T = object> extends Controller<T> {
}

export class Page<T = object> extends PageBase<T> {
constructor(app: App, model: ChildModel<T>) {
constructor(app: App, model: Model<T>) {
super(app, model);
this._addListeners();
}
Expand Down
4 changes: 2 additions & 2 deletions src/PageForServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Request, Response } from 'express';
import { type ChildModel } from 'racer';
import { type Model } from 'racer';

import { type AppForServer } from './AppForServer';
import { PageBase } from './Page';
Expand All @@ -10,7 +10,7 @@ export class PageForServer<T = object> extends PageBase<T> {
res: Response;
page: PageForServer;

constructor(app: AppForServer, model: ChildModel<T>, req: Request, res: Response) {
constructor(app: AppForServer, model: Model<T>, req: Request, res: Response) {
super(app, model);
this.req = req;
this.res = res;
Expand Down
6 changes: 3 additions & 3 deletions src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type RootModel } from 'racer';
import { type Model } from 'racer';
import tracks = require('tracks');

import { type AppBase } from './App';
Expand Down Expand Up @@ -39,13 +39,13 @@ export interface RouteMethod {
}

export interface RouteHandler {
(page: PageBase, model: RootModel, params: PageParams, next: (err?: Error) => void): void;
(page: PageBase, model: Model, params: PageParams, next: (err?: Error) => void): void;
}

export interface TransitionalRouteHandler {
(
page: PageBase,
model: RootModel,
model: Model,
params: PageParams,
next: (err?: Error) => void,
done: () => void
Expand Down

0 comments on commit 1b4d936

Please sign in to comment.