Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
chore(release): 2.0.0 🎉🎉🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsisexistence committed Jun 9, 2019
1 parent 9fe8f90 commit af5770b
Show file tree
Hide file tree
Showing 23 changed files with 253 additions and 371 deletions.
Binary file added docs/.gitbook/assets/icon_origin_225x225.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 40 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,52 @@
# Introduction

**Routeshub** is a route management library and pattern that acts as _hub_ which brings more control, stable and predictable interaction with application through declarative design
![](.gitbook/assets/icon_origin_225x225.png)

## What is it ❓
**Routeshub** is a route management library and pattern for **Angular.**

⚙ Routeshub is a route management __library and pattern for standardized managing routes
Acts as a hub, which brings more control, stable and predictable interaction with project code base through declarative design

💡 Designed to improve tuning and handling developers routes business in the more comfortable way
## What is it

⚙ A route manager. Designed to improve improve reliability and speed of development

🔩 Engineered by plugin design. It was designed to be added at any time during the development process, even for separate complicated project parts.

🔧 Modeled after a tree data structure.

🔩 Engineered as a plugin for Angular
## Support

Originally it was invented for **@angular/router.**

Support for other routing libraries is the goal**.**

## **Contributing**

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate and keep the examples consistent.

## **Changelog**

Stay tuned with [changelog](https://github.com/maktarsis/routeshub/blob/master/CHANGELOG.md) on GitHub

## Questions

If you still have the questions or suggestions, then create an [issue](https://github.com/maktarsis/routeshub/issues) or feel free to contact me on [twitter](https://twitter.com/maktarsis)

## Looking for the best

This project is neither ideal nor final.

Just a step for the better. A step to help engineers building applications better and faster.

That's why I'll be happy with any kind of involvement and I am opened to any suggestions.

## For whom ❓
{% hint style="info" %}
**Essence**

Originally it was invented and developed for those who work with **@angular/router**
It is a slightly different concept from _state management._

Support for other routing libraries is the goal
Routeshub collects and analyzes routes information to create manageable state of route_._ You can understand this concept as a **hub**.
{% endhint %}

19 changes: 8 additions & 11 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# Table of contents

* [Introduction](README.md)
* [Getting Started](getting-started/README.md)
* [Motivation](getting-started/motivation.md)
* [Installation](getting-started/installation.md)
* [Installation](installation.md)
* [Example](example/README.md)
* [Initial Code](example/initial-code.md)
* [Creating Hub](example/creating-hub.md)
* [Connecting the dots](example/connecting-the-dots.md)
* [Navigating](example/navigating.md)
* [Concepts](concepts/README.md)
* [Introduction](concepts/introduction.md)
* [Creators](concepts/creators.md)
* [Notes](concepts/notes.md)
* [Slices](concepts/slices.md)
* [Unions](concepts/unions.md)
* [API](api/README.md)
* [Interfaces](api/interfaces.md)
* [Creators](api/creators.md)
* [Directives](api/directives.md)
* [Other](api/other.md)
* [Example](example/README.md)
* [Initial Code](example/initial-code.md)
* [Creating Notes](example/creating-notes.md)
* [Creating Slices](example/creating-slices.md)
* [Connecting the dots](example/connecting-the-dots.md)
* [Navigating](example/navigating.md)
* [Functions](api/functions.md)

Binary file modified docs/api/creators.md
Binary file not shown.
Binary file modified docs/api/directives.md
Binary file not shown.
Binary file added docs/api/functions.md
Binary file not shown.
Binary file modified docs/api/interfaces.md
Binary file not shown.
Binary file removed docs/api/other.md
Binary file not shown.
54 changes: 0 additions & 54 deletions docs/concepts/creators.md

This file was deleted.

4 changes: 1 addition & 3 deletions docs/concepts/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

There are a few concepts you need to know before start:

* **Creators**
* **Notes**
* **Slices**

These concepts describe the complete process of integration routeshub into application.
* **Unions**

Binary file modified docs/concepts/notes.md
Binary file not shown.
51 changes: 32 additions & 19 deletions docs/concepts/slices.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
# Slices

Essentially, slice is an output. It just defines the enhanced route
Slice is a modular entity that contains stateful module routes

## Getting Know with Output
**There are two ways to create the slice:**

To create a slice we need :
* createRoot
* createFeature

* parent's slice
* current note
* interface that describe a new feature slice
**Root creator** _****_invokes only once to initialize the _hub_ in application. It takes initial \(app\) note and produces the slice which will be used for subsequent feature creators.

In turn the **feature creator** is responsible for relations between parent and child nodes \(slices\).

## Creating Root

Usage example:

```typescript
import { createRoot } from 'routeshub';
import { appNote, AppNote, routes } from './'

export const appSlice: Slice<AppNote> = createRoot<AppNote>(appNote);
```

## Creating Feature

Takes two arguments and two generic types \(the second is optional for children\). The first argument is a parent slice that links to this module. The second one is a note of the current module.

Usage example:

```typescript
// grabbing the feature creator and interface
import { createFeature, Slice } from 'routeshub';
// importing the parent slice
import { appSlice } from 'app/routing/hub/app.slice';
// importing module's notes and its interface
import { aboutNotes, AboutRoutes } from './about.notes';

// creating feature slice
export const aboutSlice: Slice<AboutRoutes> = createFeature<AboutRoutes>(
import { createFeature, createNote, Root, Slice } from 'routeshub';
import { aboutNote, AboutNote, routes } from './';
import { appSlice } from '../../../routing/hub';

export const aboutSlice: Slice<AboutNote> = createFeature<AboutNote>(
appSlice.about,
aboutNotes
aboutNote
);

```

{% hint style="success" %}
That's it
{% endhint %}
As we noticed earlier, **feature creator** needs the parent slice to connect it with with its note entity.

56 changes: 56 additions & 0 deletions docs/concepts/unions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Unions

Union is an entity that connects several selected slices

## Creating Union

Takes one object as argument. Value is a slice, key - its name. Invalid name will flush an error to prevent mistakes in the future.

```typescript
import { createUnion } from 'routeshub';
import { appSlice } from './hub/app.hub';
import { aboutSlice } from '../views/about/hub';
import { automobileSlice } from '../views/automobile/hub';
import { bikeSlice } from '../views/bike/hub';
import { bolidSlice } from '../views/bolid/hub';

export const union = createUnion({
app: appSlice,
about: aboutSlice,
automobiles: automobileSlice,
bikes: bikeSlice,
bolids: bolidSlice
});

```

It's ok, if you want to declare it only one time. Next time you want to use it you will need to access it in the component.

You can find unions useful because of their flexible design.

{% code-tabs %}
{% code-tabs-item title="header.component.ts" %}
```typescript
import { Component, OnInit } from '@angular/core';
import { createUnion } from 'routeshub';
import { appSlice as app } from '../../routing/hub/app.hub';
import { authSlice as auth } from '../../auth/hub';

@Component({
selector: 'app-header',
template: `
<nav>
<a navLink="{{ union.app.root.state }}">Home</a>
<a [navLink]="union.auth.signUp.state">Sign Up</a>
</nav>
`
})
export class HeaderComponent implements OnInit {
public union = createUnion({ app, auth });
}
```
{% endcode-tabs-item %}
{% endcode-tabs %}

It doesn't perform long and complicated calculations. So, you are free to use it everywhere.

Binary file modified docs/example/connecting-the-dots.md
Binary file not shown.
100 changes: 100 additions & 0 deletions docs/example/creating-hub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Creating Hub

Let's create the notes and slices

{% code-tabs %}
{% code-tabs-item title="app.hub.ts" %}
```typescript
import { createRoot, createNote, Root, Note } from 'routeshub';
import { routes } from './app.routes';

export interface AppChildrenNote extends Root {
about: Note;
}

/**
* Root is the shortcut of root path
* Designed to speed up code reusing
*/
export interface AppNote extends Root<AppChildrenNote> {
auth: Note;
notFound: Note;
}

/**
* it is equivalent of the code above
* choose the one you comfortable with
export interface AppNotes {
root: Note<AppChildrenNote>
auth: Note;
notFound: Note;
}
*/

/**
* you may be confused about the second argument
* by default route path '' transforms into property 'root'
* and '**' transforms into property 'wildcard'
*
* So, you can customize property keys through the second argument
* as illustrated below
*/
export const appNote = createNote<AppNote>(routes, { wildcard: 'notFound' });

export const appSlice: Slice<AppNote, AppChildrenNote> = createRoot<
AppNote,
AppChildrenNote
>(appNote);

```
{% endcode-tabs-item %}

{% code-tabs-item title="about.hub.ts" %}
```typescript
import { createFeature, createNote, Root, Note } from 'routeshub';
import { routes } from './about.routes';
import { appSlice } from '../../../routing/app.hub';

export type AboutNote = Root;

export const aboutNote = createNote<AboutNote>(routes);

export const aboutSlice: Slice<AboutNote> = createFeature<AboutNote>(
appSlice.about,
aboutNote
);

```
{% endcode-tabs-item %}

{% code-tabs-item title="auth.note.ts" %}
```typescript
import { createFeature, createNote, Root, Note } from 'routeshub';
import { routes } from './auth.routes';
import { appSlice } from '../../../routing/app.hub';

export interface AuthNote extends Root {
signIn: Note;
signUp: Note;
id: Note;
}

export const authNote = createNote<AuthNote>(routes);

export const authSlice: Slice<AuthNote> = createFeature<AuthNote>(
appSlice.auth,
authNote
);

```
{% endcode-tabs-item %}
{% endcode-tabs %}

{% hint style="success" %}
Setup
{% endhint %}



Loading

0 comments on commit af5770b

Please sign in to comment.