Last active
November 29, 2016 07:27
-
-
Save cevek/68c635f0b7e131960ae12b7d7c38c203 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface RouteProps { | |
search: {}; | |
urlParams: {}; | |
} | |
interface Data{ | |
a: number; | |
} | |
interface AppProps extends RouteProps { | |
data: Data; | |
} | |
interface TournamentUrlParams { | |
id: number | |
} | |
interface TournamentProps extends AppProps { | |
urlParams: TournamentUrlParams; | |
search: {boom: number, self: number} | |
} | |
interface TournamentStandingsUrlParams extends TournamentUrlParams{ | |
id: number; teamId: number | |
} | |
interface TournamentStandingsProps extends TournamentProps{ | |
urlParams: TournamentStandingsUrlParams; | |
} | |
class Component<P> { | |
props: P; | |
} | |
interface X<U, S>{ | |
search: S; | |
urlParams: U; | |
} | |
interface Props<P, S> { | |
urlParams: P; | |
search: S; | |
} | |
class Route<P, S>{ | |
params: P; | |
search: S; | |
goto(params: P, search?: S) { | |
} | |
constructor(public component: new () => Component<Props<P, S>>) { | |
} | |
addChild<PP extends P, SS extends S>(component: new () => Component<Props<PP, SS>>) { | |
return new Route<P, S>(component); | |
} | |
} | |
class App extends Component<AppProps>{ | |
static resolve() { | |
} | |
} | |
class Tournament extends Component<TournamentProps>{ | |
render() { | |
tournamentRoute.goto({id: 2}); | |
} | |
} | |
class TournamentStandings extends Component<TournamentStandingsProps>{ | |
render() { | |
tournamentRoute.goto({id: 2}); | |
} | |
} | |
var indexRoute = new Route(App); | |
var tournamentRoute2 = new Route(Tournament); | |
tournamentRoute2.params.id; | |
tournamentRoute2.search.boom | |
var tournamentRoute = indexRoute.addChild(Tournament); | |
var tournamentStandingRoute = indexRoute.addChild(TournamentStandings); | |
// tournamentRoute.goto({x:1}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment