An open API service indexing awesome lists of open source software.

https://github.com/eneajaho/observable-store

An observable store built with rxjs, ideal for small/medium projects.
https://github.com/eneajaho/observable-store

angular rxjs store

Last synced: 5 months ago
JSON representation

An observable store built with rxjs, ideal for small/medium projects.

Awesome Lists containing this project

README

          

## Run Project Locally - [Live project][https://observable-store.eneajaho.me/]

**Install node modules**
```bash
npm install
```

**Start Angular app**
```bash
ng s -o
```

**Start json-server**
```bash
json-server --watch db.json
```

### What's included
- Smart components (Containers)
- Dumb components (Presenters)
- Lazy loading modules
- Reactive forms
- Interceptors
- Resolvers
- Services
- Facades
- Guards
- Pipes
- Models
- **Observable Store** - [Docs](https://github.com/eneajaho/observable-store/blob/master/src/app/store/README.md)

### CRUD data in services or components
```js
constructor(private http: HttpClient, private store: Store) { }

getFavorites(): Observable<{ id: number }[]> {
return this.http.get<{ id: number }[]>(`${this.api}/favorites`)
.pipe(tap(res => this.store.set('favorites', res)));
}

addFavorite(id: number): Observable {
return this.http.post(`${this.api}/favorites`, { id }).pipe(
tap(() => this.store.setItem('favorites', id, { id }))
);
}

removeFavorite(id: number): Observable {
return this.http.delete(`${this.api}/favorites/${id}`).pipe(
tap(() => this.store.removeItem('favorites', id))
);
}
```

### Getting data from store
```js
movies$: Observable;
favorites$: Observable;

constructor(private store: Store) { }

ngOnInit() {
this.movies$ = this.store.select('movies');
this.favorites$ = this.store.select('favorites');
}
```

### Screenshot
![Movies Store](https://i.imgur.com/WWKVb3X.jpg)

[https://observable-store.eneajaho.me/]: https://observable-store.eneajaho.me/

---

> License: **MIT**

> Author: **Enea Jahollari**