Skip to content

Commit

Permalink
Merge remote-tracking branch 'PR6/master' into dev
Browse files Browse the repository at this point in the history
* PR6/master:
  added types for transition options and nodeName
  added typescript typings
  typescript typings wip
  docs(README): Coorect peer deps
  • Loading branch information
LeonardoGentile committed Jun 11, 2018
2 parents fe56b2c + 4303d2f commit 5b8cb47
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage
dist
docs/dist
node_modules
.idea
npm-debug.log
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This plugin can also be used standalone together with mobx.

## Requirements

- __router5 >= 5.0.0__
- __router5 >= 6.1.2__
- __mobx >= 4.0.0__

These are considered `peerDependencies` that means they should exist in your installation, you should install them yourself to make this plugin work. The package won't install them as dependencies.
Expand Down
40 changes: 40 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {State} from "router5";
import {IComputedValue} from "mobx/lib/core/computedvalue";
import {Route, Router} from "router5/create-router";
import {Options} from "router5/core/navigation";

declare module "mobx-router5" {
import {PluginFactory} from "router5/core/plugins";
import {Params} from "router5";

class RouterStore {
public router: Router;
public previousRoute: Route;
public transitionRoute: Route;
public transitionError: any;
public intersectionNode: string;
// public toActivate: IObservableArray<any>;
// public toDeactivate: IObservableArray<any>;

public setRouter: (router: Router) => void;
public updateRoute: (routeType: string, route: Route) => void;
public resetRoute: (routeType: string) => void;
public onTransitionStart: (route: Route, previousRoute: Route) => void;
public onTransitionSuccess: (route: Route, previousRoute: Route, opts: Options) => void;
public onTransitionCancel: (route: Route, previousRoute: Route) => void;
public onTransitionError: (route: Route, previousRoute: Route, transitionError: any) => void;
public clearErrors: () => void;
public navigate: (toRoute: string, params?: Params) => void;
public shouldUpdateNodeFactory: (nodeName: string) => IComputedValue<(toState: State, fromState?: State) => Boolean>;
}

function mobxPlugin(routerStore: RouterStore): PluginFactory;

namespace RouterStore {}
namespace mobxPlugin {}

export {
RouterStore,
mobxPlugin,
};
}

0 comments on commit 5b8cb47

Please sign in to comment.