Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions most-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Stream} from 'most';
import {Pathname, Location} from '@cycle/history/lib/interfaces';
import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces';
export interface RouterSource {
history$: Stream<Location>;
path(pathname: Pathname): RouterSource;
define(routes: RouteDefinitions): Stream<SwitchPathReturn>;
createHref(path: Pathname): Pathname;
}
9 changes: 9 additions & 0 deletions rx-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Observable} from 'rx';
import {Pathname, Location} from '@cycle/history/lib/interfaces';
import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces';
export interface RouterSource {
history$: Observable<Location>;
path(pathname: Pathname): RouterSource;
define(routes: RouteDefinitions): Observable<SwitchPathReturn>;
createHref(path: Pathname): Pathname;
}
9 changes: 9 additions & 0 deletions rxjs-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Observable} from 'rxjs';
import {Pathname, Location} from '@cycle/history/lib/interfaces';
import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces';
export interface RouterSource {
history$: Observable<Location>;
path(pathname: Pathname): RouterSource;
define(routes: RouteDefinitions): Observable<SwitchPathReturn>;
createHref(path: Pathname): Pathname;
}
6 changes: 3 additions & 3 deletions src/RouterSource.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {StreamAdapter} from '@cycle/base';
import {Location, Pathname} from '@cycle/history/lib/interfaces';
import switchPath, {RouteDefinitions} from 'switch-path';

import switchPath from 'switch-path';
import {RouteDefinitions, SwitchPathReturn} from './interfaces';
import * as util from './util';

function isStrictlyInScope(namespace: Pathname[], path: Pathname): boolean {
Expand Down Expand Up @@ -39,7 +39,7 @@ export class RouterSource {
let match$ = this._runSA.remember(this.history$
.map((location: Location) => {
const filteredPath = getFilteredPath(namespace, location.pathname);
const {path, value} = switchPath(filteredPath, routes);
const {path, value} = <SwitchPathReturn>switchPath(filteredPath, routes);
return {path, value, location, createHref};
}));

Expand Down
1 change: 0 additions & 1 deletion src/custom-typings/main.d.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/custom-typings/switch-path.d.ts

This file was deleted.

8 changes: 8 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface RouteDefinitions {
[sourcePath: string]: any;
}

export interface SwitchPathReturn {
path: string;
value: any;
}
3 changes: 3 additions & 0 deletions src/switch-path.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'switch-path' {
export default function switchPath(sourcePath: string, routes: {}): {};
}
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
"tabSize": 2
},
"files": [
"typings/main.d.ts",
"src/custom-typings/main.d.ts",
"src/index.ts"
"src/index.ts",
"src/switch-path.d.ts"
],
"exclude": [
"node_modules"
Expand Down
3 changes: 0 additions & 3 deletions typings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"name": "cyclic-router",
"dependencies": {
"@cycle/history": "npm:@cycle/history"
},
"ambientDevDependencies": {
"mocha": "github:DefinitelyTyped/DefinitelyTyped/mocha/mocha.d.ts#d6dd320291705694ba8e1a79497a908e9f5e6617",
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#20e1eb9616922d382d918cc5a21870a9dbe255f5"
Expand Down
9 changes: 9 additions & 0 deletions xstream-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Stream} from 'xstream';
import {Pathname} from '@cycle/history/lib/interfaces';
import {RouteDefinitions, SwitchPathReturn} from './lib/interfaces';
export interface RouterSource {
history$: Stream<Location>;
path(pathname: Pathname): RouterSource;
define(routes: RouteDefinitions): Stream<SwitchPathReturn>;
createHref(path: Pathname): Pathname;
}