@real-router/core 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,10 +11,6 @@ Core router implementation for Real-Router.
11
11
  npm install @real-router/core
12
12
  # or
13
13
  pnpm add @real-router/core
14
- # or
15
- yarn add @real-router/core
16
- # or
17
- bun add @real-router/core
18
14
  ```
19
15
 
20
16
  ## Quick Start
@@ -34,29 +30,29 @@ router.start();
34
30
  router.navigate("users.profile", { id: "123" });
35
31
  ```
36
32
 
37
- ## API Reference
33
+ ---
34
+
35
+ ## Essential API
38
36
 
39
37
  ### `createRouter(routes?, options?, dependencies?)`
40
38
 
41
- Creates a new router instance.
39
+ Creates a new router instance. [Wiki](https://github.com/greydragon888/real-router/wiki/createRouter)
42
40
 
43
41
  ```typescript
44
42
  const router = createRouter(
45
43
  routes, // Route[] - route definitions
46
44
  options, // Partial<Options> - router options
47
- dependencies // object - dependency injection
45
+ dependencies, // object - dependency injection
48
46
  );
49
47
  ```
50
48
 
51
49
  ---
52
50
 
53
- ## Router Methods
54
-
55
51
  ### Lifecycle
56
52
 
57
- #### `router.start(startPath?)`
53
+ #### `router.start(startPath?, done?)`
58
54
 
59
- Starts the router. Optionally accepts an initial path.
55
+ Starts the router. [Wiki](https://github.com/greydragon888/real-router/wiki/start)
60
56
 
61
57
  ```typescript
62
58
  router.start();
@@ -68,21 +64,11 @@ router.start("/users/123", (err, state) => {
68
64
 
69
65
  #### `router.stop()`
70
66
 
71
- Stops the router.
72
-
73
- ```typescript
74
- router.stop();
75
- ```
67
+ Stops the router. [Wiki](https://github.com/greydragon888/real-router/wiki/stop)
76
68
 
77
69
  #### `router.isStarted()`
78
70
 
79
- Returns whether the router is started.
80
-
81
- ```typescript
82
- if (router.isStarted()) {
83
- router.navigate("home");
84
- }
85
- ```
71
+ Returns whether the router is started. [Wiki](https://github.com/greydragon888/real-router/wiki/isStarted)
86
72
 
87
73
  ---
88
74
 
@@ -90,208 +76,46 @@ if (router.isStarted()) {
90
76
 
91
77
  #### `router.navigate(name, params?, options?, done?)`
92
78
 
93
- Navigates to a route by name.
79
+ Navigates to a route by name. Returns a cancel function. [Wiki](https://github.com/greydragon888/real-router/wiki/navigate)
94
80
 
95
81
  ```typescript
96
82
  router.navigate("users");
97
83
  router.navigate("users.profile", { id: "123" });
98
84
  router.navigate("users.profile", { id: "123" }, { replace: true });
99
- router.navigate("users.profile", { id: "123" }, { replace: true }, (err, state) => {
85
+
86
+ // With callback
87
+ router.navigate("users", {}, {}, (err, state) => {
100
88
  if (err) console.error(err);
101
89
  });
102
- ```
103
-
104
- #### `router.navigateToDefault(options?, done?)`
105
-
106
- Navigates to the default route.
107
-
108
- ```typescript
109
- router.navigateToDefault();
110
- ```
111
-
112
- #### `router.isNavigating()`
113
90
 
114
- Returns whether a navigation is in progress.
115
-
116
- ```typescript
117
- if (!router.isNavigating()) {
118
- router.navigate("home");
119
- }
120
- ```
121
-
122
- #### Cancelling Navigation
123
-
124
- The `navigate()` method returns a cancel function that can be used to abort the navigation.
125
-
126
- ```typescript
91
+ // Cancellation
127
92
  const cancel = router.navigate("users.profile", { id: "123" });
128
-
129
- // Later, if you need to cancel:
130
- cancel();
93
+ cancel(); // abort navigation
131
94
  ```
132
95
 
133
- ---
134
-
135
- ### State
136
-
137
96
  #### `router.getState()`
138
97
 
139
- Returns the current router state.
98
+ Returns the current router state. [Wiki](https://github.com/greydragon888/real-router/wiki/getState)
140
99
 
141
100
  ```typescript
142
101
  const state = router.getState();
143
102
  // { name: "users.profile", params: { id: "123" }, path: "/users/123" }
144
103
  ```
145
104
 
146
- #### `router.getPreviousState()`
147
-
148
- Returns the previous router state.
149
-
150
- ```typescript
151
- const prev = router.getPreviousState();
152
- ```
153
-
154
- #### `router.setState(state)`
155
-
156
- Sets the router state directly (without navigation).
157
-
158
- ```typescript
159
- router.setState({ name: "home", params: {}, path: "/" });
160
- ```
161
-
162
- #### `router.areStatesEqual(state1, state2, ignoreQueryParams?)`
163
-
164
- Compares two states for equality.
165
-
166
- ```typescript
167
- router.areStatesEqual(stateA, stateB);
168
- router.areStatesEqual(stateA, stateB, true); // ignore query params
169
- ```
170
-
171
- ---
172
-
173
- ### Routes
174
-
175
- #### `router.addRoute(route)`
176
-
177
- Adds a route definition.
178
-
179
- ```typescript
180
- router.addRoute({ name: "settings", path: "/settings" });
181
- router.addRoute({ name: "settings.profile", path: "/profile" });
182
- ```
183
-
184
- #### `router.removeRoute(name)`
185
-
186
- Removes a route by name.
187
-
188
- ```typescript
189
- router.removeRoute("settings");
190
- ```
191
-
192
- #### `router.getRoute(name)`
193
-
194
- Gets a route definition by name.
195
-
196
- ```typescript
197
- const route = router.getRoute("users");
198
- ```
199
-
200
- #### `router.hasRoute(name)`
201
-
202
- Checks if a route exists.
203
-
204
- ```typescript
205
- if (router.hasRoute("users")) {
206
- router.navigate("users");
207
- }
208
- ```
209
-
210
- #### `router.clearRoutes()`
211
-
212
- Removes all routes from the router.
213
-
214
- ```typescript
215
- router.clearRoutes().addRoute([
216
- { name: "home", path: "/" },
217
- { name: "about", path: "/about" },
218
- ]);
219
- ```
220
-
221
- #### `router.updateRoute(name, updates)`
222
-
223
- Updates configuration of an existing route.
224
-
225
- ```typescript
226
- router.updateRoute("users", {
227
- defaultParams: { page: 1 },
228
- canActivate: authGuard,
229
- });
230
-
231
- // Remove configuration by setting to null
232
- router.updateRoute("oldRoute", { forwardTo: null });
233
- ```
234
-
235
- ---
236
-
237
- ### Path Building & Matching
238
-
239
- #### `router.buildPath(name, params?)`
240
-
241
- Builds a URL path from route name and params.
242
-
243
- ```typescript
244
- const path = router.buildPath("users.profile", { id: "123" });
245
- // "/users/123"
246
- ```
247
-
248
- #### `router.buildState(name, params?)`
249
-
250
- Builds a state object from route name and params.
251
-
252
- ```typescript
253
- const state = router.buildState("users.profile", { id: "123" });
254
- // { name: "users.profile", params: { id: "123" }, path: "/users/123", meta: {...} }
255
- ```
256
-
257
- #### `router.matchPath(path)`
258
-
259
- Matches a URL path to a state.
260
-
261
- ```typescript
262
- const state = router.matchPath("/users/123");
263
- // { name: "users.profile", params: { id: "123" }, ... }
264
- ```
265
-
266
- #### `router.isActiveRoute(name, params?, strictEquality?, ignoreQueryParams?)`
267
-
268
- Checks if a route is currently active.
269
-
270
- ```typescript
271
- router.isActiveRoute("users"); // true if current route starts with "users"
272
- router.isActiveRoute("users", { id: "123" }); // true if params match
273
- router.isActiveRoute("users", { id: "123" }, true); // strict equality
274
- ```
275
-
276
- #### `router.forward(fromRoute, toRoute)`
277
-
278
- Sets up route forwarding (redirect).
105
+ #### `router.navigateToDefault(options?, done?)`
279
106
 
280
- ```typescript
281
- router.forward("old-page", "new-page");
282
- // Navigating to "old-page" will redirect to "new-page"
283
- ```
107
+ Navigates to the default route. [Wiki](https://github.com/greydragon888/real-router/wiki/navigateToDefault)
284
108
 
285
109
  ---
286
110
 
287
111
  ### Guards
288
112
 
289
- #### `router.canActivate(name, canActivateFn)`
113
+ #### `router.canActivate(name, guardFactory)`
290
114
 
291
- Registers a guard for route activation.
115
+ Registers a guard for route activation. [Wiki](https://github.com/greydragon888/real-router/wiki/canActivate)
292
116
 
293
117
  ```typescript
294
- router.canActivate("admin", (toState, fromState, done) => {
118
+ router.canActivate("admin", () => (toState, fromState, done) => {
295
119
  if (!isAuthenticated()) {
296
120
  done({ redirect: { name: "login" } });
297
121
  } else {
@@ -300,12 +124,12 @@ router.canActivate("admin", (toState, fromState, done) => {
300
124
  });
301
125
  ```
302
126
 
303
- #### `router.canDeactivate(name, canDeactivateFn)`
127
+ #### `router.canDeactivate(name, guardFactory)`
304
128
 
305
- Registers a guard for route deactivation.
129
+ Registers a guard for route deactivation. [Wiki](https://github.com/greydragon888/real-router/wiki/canDeactivate)
306
130
 
307
131
  ```typescript
308
- router.canDeactivate("editor", (toState, fromState, done) => {
132
+ router.canDeactivate("editor", () => (toState, fromState, done) => {
309
133
  if (hasUnsavedChanges()) {
310
134
  done({ error: new Error("Unsaved changes") });
311
135
  } else {
@@ -314,83 +138,57 @@ router.canDeactivate("editor", (toState, fromState, done) => {
314
138
  });
315
139
  ```
316
140
 
317
- #### `router.clearCanActivate(name)`
318
-
319
- Clears activation guard for a route.
320
-
321
- #### `router.clearCanDeactivate(name)`
322
-
323
- Clears deactivation guard for a route.
324
-
325
141
  ---
326
142
 
327
- ### Events & Subscriptions
143
+ ### Events
328
144
 
329
145
  #### `router.subscribe(listener)`
330
146
 
331
- Subscribes to state changes.
147
+ Subscribes to successful transitions. [Wiki](https://github.com/greydragon888/real-router/wiki/subscribe)
332
148
 
333
149
  ```typescript
334
150
  const unsubscribe = router.subscribe(({ route, previousRoute }) => {
335
151
  console.log("Navigation:", previousRoute?.name, "→", route.name);
336
152
  });
337
-
338
- // Later: unsubscribe()
339
153
  ```
340
154
 
341
155
  #### `router.addEventListener(event, listener)`
342
156
 
343
- Adds an event listener. Returns an unsubscribe function.
157
+ Adds an event listener. Returns an unsubscribe function. [Wiki](https://github.com/greydragon888/real-router/wiki/addEventListener)
344
158
 
345
159
  ```typescript
346
160
  import { events } from "@real-router/core";
347
161
 
348
- const unsubscribe = router.addEventListener(events.TRANSITION_START, (toState, fromState) => {
162
+ router.addEventListener(events.TRANSITION_START, (toState, fromState) => {
349
163
  console.log("Starting:", toState.name);
350
164
  });
351
165
 
352
- router.addEventListener(events.TRANSITION_SUCCESS, (toState, fromState) => {
353
- console.log("Success:", toState.name);
354
- });
355
-
356
- router.addEventListener(events.TRANSITION_ERROR, (toState, fromState, error) => {
357
- console.error("Error:", error);
358
- });
359
-
360
166
  // Available events:
361
- // events.ROUTER_START, events.ROUTER_STOP
362
- // events.TRANSITION_START, events.TRANSITION_SUCCESS
363
- // events.TRANSITION_ERROR, events.TRANSITION_CANCEL
167
+ // ROUTER_START, ROUTER_STOP
168
+ // TRANSITION_START, TRANSITION_SUCCESS, TRANSITION_ERROR, TRANSITION_CANCEL
364
169
  ```
365
170
 
366
- #### `router.removeEventListener(event, listener)`
367
-
368
- Removes an event listener.
369
-
370
171
  ---
371
172
 
372
173
  ### Plugins
373
174
 
374
- #### `router.usePlugin(plugin)`
175
+ #### `router.usePlugin(pluginFactory)`
375
176
 
376
- Registers a plugin. Returns an unsubscribe function.
177
+ Registers a plugin. Returns an unsubscribe function. [Wiki](https://github.com/greydragon888/real-router/wiki/usePlugin)
377
178
 
378
179
  ```typescript
379
180
  import { browserPluginFactory } from "@real-router/browser-plugin";
380
181
 
381
182
  const unsubscribe = router.usePlugin(browserPluginFactory());
382
-
383
- // Later, to remove the plugin:
384
- unsubscribe();
385
183
  ```
386
184
 
387
185
  ---
388
186
 
389
187
  ### Middleware
390
188
 
391
- #### `router.useMiddleware(middleware)`
189
+ #### `router.useMiddleware(middlewareFactory)`
392
190
 
393
- Registers middleware.
191
+ Registers middleware for the navigation pipeline. [Wiki](https://github.com/greydragon888/real-router/wiki/useMiddleware)
394
192
 
395
193
  ```typescript
396
194
  router.useMiddleware((router) => (toState, fromState, done) => {
@@ -399,121 +197,213 @@ router.useMiddleware((router) => (toState, fromState, done) => {
399
197
  });
400
198
  ```
401
199
 
402
- #### `router.clearMiddleware()`
403
-
404
- Clears all middleware.
405
-
406
200
  ---
407
201
 
408
- ### Options
409
-
410
- #### `router.getOptions()`
411
-
412
- Returns router options.
413
-
414
- ```typescript
415
- const options = router.getOptions();
416
- ```
202
+ ## Advanced API
417
203
 
418
- #### `router.setOption(name, value)`
204
+ ### Routes
419
205
 
420
- Sets a router option. Can only be used before `router.start()`.
206
+ #### `router.addRoute(route: Route): void`
207
+ Add a route definition at runtime.\
208
+ `route: Route` — route configuration object\
209
+ Returns: `void`\
210
+ [Wiki](https://github.com/greydragon888/real-router/wiki/addRoute)
211
+ #### `router.removeRoute(name: string): void`
212
+ Remove a route by name.\
213
+ `name: string` — route name to remove\
214
+ Returns: `void`\
215
+ [Wiki](https://github.com/greydragon888/real-router/wiki/removeRoute)
216
+ #### `router.getRoute(name: string): Route | undefined`
217
+ Get route definition by name.\
218
+ `name: string` — route name\
219
+ Returns: `Route | undefined`\
220
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getRoute)
221
+ #### `router.hasRoute(name: string): boolean`
222
+ Check if a route exists.\
223
+ `name: string` — route name\
224
+ Returns: `boolean`\
225
+ [Wiki](https://github.com/greydragon888/real-router/wiki/hasRoute)
226
+ #### `router.clearRoutes(): void`
227
+ Remove all routes.
228
+ Returns: `void`\
229
+ [Wiki](https://github.com/greydragon888/real-router/wiki/clearRoutes)
230
+ #### `router.updateRoute(name: string, updates: Partial<Route>): void`
231
+ Update route configuration.\
232
+ `name: string` — route name\
233
+ `updates: Partial<Route>` — properties to update\
234
+ Returns: `void`\
235
+ [Wiki](https://github.com/greydragon888/real-router/wiki/updateRoute)
236
+ #### `router.forward(fromRoute: string, toRoute: string): void`
237
+ Set up route forwarding (redirect).\
238
+ `fromRoute: string` — source route name\
239
+ `toRoute: string` — target route name\
240
+ Returns: `void`\
241
+ [Wiki](https://github.com/greydragon888/real-router/wiki/forward)
242
+ ---
421
243
 
422
- ```typescript
423
- router.setOption("defaultRoute", "home");
424
- router.setOption("trailingSlash", "never");
425
- ```
244
+ ### State Utilities
245
+
246
+ #### `router.getPreviousState(): State | undefined`
247
+ Get previous router state.\
248
+ Returns: `State | undefined`\
249
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getPreviousState)
250
+ #### `router.setState(state: State): void`
251
+ Set state directly without navigation.\
252
+ `state: State` — state to set\
253
+ Returns: `void`\
254
+ [Wiki](https://github.com/greydragon888/real-router/wiki/setState)
255
+ #### `router.makeState(name: string, params?: Params, path?: string, meta?: object): State`
256
+ Create a state object.\
257
+ `name: string` — route name\
258
+ `params?: Params` — route parameters\
259
+ `path?: string` — URL path\
260
+ `meta?: object` — metadata\
261
+ Returns: `State`\
262
+ [Wiki](https://github.com/greydragon888/real-router/wiki/makeState)
263
+ #### `router.buildState(name: string, params?: Params): State | undefined`
264
+ Build state from route name.\
265
+ `name: string` — route name\
266
+ `params?: Params` — route parameters\
267
+ Returns: `State | undefined`\
268
+ [Wiki](https://github.com/greydragon888/real-router/wiki/buildState)
269
+ #### `router.areStatesEqual(state1: State, state2: State, ignoreQueryParams?: boolean): boolean`
270
+ Compare two states for equality.\
271
+ `state1: State` — first state\
272
+ `state2: State` — second state\
273
+ `ignoreQueryParams?: boolean` — ignore query params (default: true)Returns: `boolean`\
274
+ [Wiki](https://github.com/greydragon888/real-router/wiki/areStatesEqual)
275
+ #### `router.areStatesDescendants(parentState: State, childState: State): boolean`
276
+ Check if child state is descendant of parent.\
277
+ `parentState: State` — parent state\
278
+ `childState: State` — child state\
279
+ Returns: `boolean`\
280
+ [Wiki](https://github.com/greydragon888/real-router/wiki/areStatesDescendants)
281
+ ---
426
282
 
283
+ ### Path Operations
284
+
285
+ #### `router.buildPath(name: string, params?: Params): string`
286
+ Build URL path from route name.\
287
+ `name: string` — route name\
288
+ `params?: Params` — route parameters\
289
+ Returns: `string`\
290
+ [Wiki](https://github.com/greydragon888/real-router/wiki/buildPath)
291
+ #### `router.matchPath(path: string): State | undefined`
292
+ Match URL path to state.\
293
+ `path: string` — URL path to match\
294
+ Returns: `State | undefined`\
295
+ [Wiki](https://github.com/greydragon888/real-router/wiki/matchPath)
296
+ #### `router.isActiveRoute(name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean): boolean`
297
+ Check if route is currently active.\
298
+ `name: string` — route name\
299
+ `params?: Params` — route parameters\
300
+ `strictEquality?: boolean` — exact match (default: false)`ignoreQueryParams?: boolean` — ignore query params (default: true)Returns: `boolean`\
301
+ [Wiki](https://github.com/greydragon888/real-router/wiki/isActiveRoute)
302
+ #### `router.setRootPath(rootPath: string): void`
303
+ Set root path prefix for all routes.\
304
+ `rootPath: string` — root path prefix\
305
+ Returns: `void`\
306
+ [Wiki](https://github.com/greydragon888/real-router/wiki/setRootPath)
307
+ #### `router.getRootPath(): string`
308
+ Get root path prefix.\
309
+ Returns: `string`\
310
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getRootPath)
427
311
  ---
428
312
 
429
313
  ### Dependencies
430
314
 
431
- #### `router.getDependencies()`
432
-
433
- Returns a shallow copy of all injected dependencies.
434
-
435
- ```typescript
436
- const deps = router.getDependencies();
437
- ```
438
-
439
- #### `router.getDependency(name)`
440
-
441
- Returns a specific dependency.
442
-
443
- ```typescript
444
- const api = router.getDependency("api");
445
- ```
446
-
447
- #### `router.setDependency(name, value)`
448
-
449
- Sets a single dependency.
450
-
451
- ```typescript
452
- router.setDependency("api", apiClient);
453
- ```
454
-
455
- #### `router.setDependencies(deps)`
456
-
457
- Sets multiple dependencies at once.
458
-
459
- ```typescript
460
- router.setDependencies({
461
- api: apiClient,
462
- logger: console,
463
- cache: cacheService,
464
- });
465
- ```
466
-
467
- #### `router.hasDependency(name)`
468
-
469
- Checks if a dependency exists.
470
-
471
- ```typescript
472
- if (router.hasDependency("api")) {
473
- const api = router.getDependency("api");
474
- }
475
- ```
476
-
477
- #### `router.removeDependency(name)`
478
-
479
- Removes a dependency.
480
-
481
- ```typescript
482
- router.removeDependency("tempService");
483
- ```
484
-
485
- #### `router.resetDependencies()`
486
-
487
- Removes all dependencies.
488
-
489
- ```typescript
490
- router.resetDependencies();
491
- ```
492
-
315
+ #### `router.getDependency(name: string): unknown`
316
+ Get a dependency by name.\
317
+ `name: string` dependency name\
318
+ Returns: `unknown`\
319
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getDependency)
320
+ #### `router.getDependencies(): Dependencies`
321
+ Get all dependencies.\
322
+ Returns: `Dependencies`\
323
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getDependencies)
324
+ #### `router.setDependency(name: string, value: unknown): void`
325
+ Set a dependency.\
326
+ `name: string` — dependency name\
327
+ `value: unknown` — dependency value\
328
+ Returns: `void`\
329
+ [Wiki](https://github.com/greydragon888/real-router/wiki/setDependency)
330
+ #### `router.setDependencies(deps: Dependencies): void`
331
+ Set multiple dependencies.\
332
+ `deps: Dependencies` — dependencies object\
333
+ Returns: `void`\
334
+ [Wiki](https://github.com/greydragon888/real-router/wiki/setDependencies)
335
+ #### `router.hasDependency(name: string): boolean`
336
+ Check if dependency exists.\
337
+ `name: string` — dependency name\
338
+ Returns: `boolean`\
339
+ [Wiki](https://github.com/greydragon888/real-router/wiki/hasDependency)
340
+ #### `router.removeDependency(name: string): void`
341
+ Remove a dependency.\
342
+ `name: string` — dependency name\
343
+ Returns: `void`\
344
+ [Wiki](https://github.com/greydragon888/real-router/wiki/removeDependency)
345
+ #### `router.resetDependencies(): void`
346
+ Remove all dependencies.\
347
+ Returns: `void`\
348
+ [Wiki](https://github.com/greydragon888/real-router/wiki/resetDependencies)
493
349
  ---
494
350
 
495
- ### Cloning
496
-
497
- #### `router.clone(dependencies?)`
498
-
499
- Creates a clone of the router with the same configuration.
351
+ ### Options
500
352
 
501
- ```typescript
502
- // Basic cloning
503
- const clonedRouter = router.clone();
504
-
505
- // SSR: Clone with request-specific dependencies
506
- app.get("*", (req, res) => {
507
- const ssrRouter = router.clone({ request: req });
508
- ssrRouter.start(req.url, (err, state) => {
509
- // Render with state...
510
- });
511
- });
512
- ```
353
+ #### `router.getOptions(): Options`
354
+ Get router options.\
355
+ Returns: `Options`\
356
+ [Wiki](https://github.com/greydragon888/real-router/wiki/getOptions)
357
+ #### `router.setOption(name: string, value: unknown): void`
358
+ Set a router option. Must be called before `start()`.\
359
+ `name: string` option name\
360
+ `value: unknown` option value\
361
+ Returns: `void`\
362
+ [Wiki](https://github.com/greydragon888/real-router/wiki/setOption)
363
+ ---
513
364
 
365
+ ### Other
366
+
367
+ #### `router.clone(dependencies?: Dependencies): Router`
368
+ Clone router for SSR.\
369
+ `dependencies?: Dependencies` — override dependencies\
370
+ Returns: `Router`\
371
+ [Wiki](https://github.com/greydragon888/real-router/wiki/clone)
372
+ #### `router.isNavigating(): boolean`
373
+ Check if navigation is in progress.\
374
+ Returns: `boolean`\
375
+ [Wiki](https://github.com/greydragon888/real-router/wiki/isNavigating)
376
+ #### `router.isActive(name: string, params?: Params, strictEquality?: boolean, ignoreQueryParams?: boolean): boolean`
377
+ Alias for `isActiveRoute`.\
378
+ `name: string` — route name\
379
+ `params?: Params` — route parameters\
380
+ `strictEquality?: boolean` — exact match\
381
+ `ignoreQueryParams?: boolean` — ignore query params\
382
+ Returns: `boolean`\
383
+ [Wiki](https://github.com/greydragon888/real-router/wiki/isActive)
384
+ #### `router.clearCanActivate(name: string): void`
385
+ Clear activation guard for a route.\
386
+ `name: string` — route name\
387
+ Returns: `void`\
388
+ [Wiki](https://github.com/greydragon888/real-router/wiki/clearCanActivate)
389
+ #### `router.clearCanDeactivate(name: string): void`
390
+ Clear deactivation guard for a route.\
391
+ `name: string` — route name\
392
+ Returns: `void`\
393
+ [Wiki](https://github.com/greydragon888/real-router/wiki/clearCanDeactivate)
394
+ #### `router.clearMiddleware(): void`
395
+ Clear all middleware.\
396
+ Returns: `void`\
397
+ [Wiki](https://github.com/greydragon888/real-router/wiki/clearMiddleware)
398
+ #### `router.removeEventListener(event: string, listener: Function): void`
399
+ Remove event listener.\
400
+ `event: string` — event name\
401
+ `listener: Function` — listener to remove\
402
+ Returns: `void`\
403
+ [Wiki](https://github.com/greydragon888/real-router/wiki/removeEventListener)
514
404
  ---
515
405
 
516
- ## Options
406
+ ## Configuration
517
407
 
518
408
  ```typescript
519
409
  interface Options {
@@ -530,9 +420,13 @@ interface Options {
530
420
  }
531
421
  ```
532
422
 
423
+ See [RouterOptions](https://github.com/greydragon888/real-router/wiki/RouterOptions) for detailed documentation.
424
+
425
+ ---
426
+
533
427
  ## Observable Support
534
428
 
535
- The router implements the Observable interface:
429
+ The router implements the [TC39 Observable](https://github.com/tc39/proposal-observable) interface:
536
430
 
537
431
  ```typescript
538
432
  import { from } from "rxjs";
@@ -542,7 +436,11 @@ from(router).subscribe(({ route, previousRoute }) => {
542
436
  });
543
437
  ```
544
438
 
545
- ### RouterError
439
+ See [Symbol.observable](https://github.com/greydragon888/real-router/wiki/observable) for details.
440
+
441
+ ---
442
+
443
+ ## Error Handling
546
444
 
547
445
  Navigation errors are instances of `RouterError`:
548
446
 
@@ -551,37 +449,24 @@ import { RouterError, errorCodes } from "@real-router/core";
551
449
 
552
450
  router.navigate("users", {}, {}, (err, state) => {
553
451
  if (err instanceof RouterError) {
554
- switch (err.code) {
555
- case errorCodes.ROUTE_NOT_FOUND:
556
- console.log("Route not found");
557
- break;
558
- case errorCodes.CANNOT_ACTIVATE:
559
- console.log("Activation blocked by guard");
560
- break;
561
- case errorCodes.CANNOT_DEACTIVATE:
562
- console.log("Deactivation blocked by guard");
563
- break;
564
- case errorCodes.TRANSITION_CANCELLED:
565
- console.log("Navigation was cancelled");
566
- break;
567
- }
452
+ console.log(err.code, err.message);
568
453
  }
569
454
  });
570
455
  ```
571
456
 
572
- ### Error Codes
457
+ | Code | Description |
458
+ | ------------------- | ------------------------------ |
459
+ | `ROUTE_NOT_FOUND` | Route doesn't exist |
460
+ | `CANNOT_ACTIVATE` | Blocked by canActivate guard |
461
+ | `CANNOT_DEACTIVATE` | Blocked by canDeactivate guard |
462
+ | `CANCELLED` | Navigation was cancelled |
463
+ | `SAME_STATES` | Already at target route |
464
+ | `NOT_STARTED` | Router not started |
465
+ | `ALREADY_STARTED` | Router already started |
573
466
 
574
- ```typescript
575
- errorCodes.ROUTER_NOT_STARTED // "NOT_STARTED"
576
- errorCodes.ROUTER_ALREADY_STARTED // "ALREADY_STARTED"
577
- errorCodes.NO_START_PATH_OR_STATE // "NO_START_PATH_OR_STATE"
578
- errorCodes.ROUTE_NOT_FOUND // "ROUTE_NOT_FOUND"
579
- errorCodes.SAME_STATES // "SAME_STATES"
580
- errorCodes.CANNOT_DEACTIVATE // "CANNOT_DEACTIVATE"
581
- errorCodes.CANNOT_ACTIVATE // "CANNOT_ACTIVATE"
582
- errorCodes.TRANSITION_ERR // "TRANSITION_ERR"
583
- errorCodes.TRANSITION_CANCELLED // "CANCELLED"
584
- ```
467
+ See [RouterError](https://github.com/greydragon888/real-router/wiki/RouterError) and [Error Codes](https://github.com/greydragon888/real-router/wiki/error-codes) for details.
468
+
469
+ ---
585
470
 
586
471
  ## Related Packages
587
472