Skip to content

Commit 312d197

Browse files
authored
fix: improve change detection & fix multi-tabs demo example (#56)
* dev: fixes & improvements - update rxdb to latest - bump Angular peerDep to min 14 - fix rxjs peerDep - improve change detection by introducing internal ticks with zone/zoneless to eliminate a need for custom async pipe for Angular with RxDB - fix multi-tabs demo example // Collection - use angular inject for DI in collection service (min 14) - improve typings & work with local documents, return json instead doc instance - persist/restore local doc to/from URL via angular router - simplify examples with this new local persist - fix usage of local docs in signals (filter example) - update Readme, simplify demo file structure
1 parent 1fccdde commit 312d197

36 files changed

+710
-543
lines changed

.github/workflows/main.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: Build, Test & Deploy demo
33
# Controls when the action will run.
44
on:
55
# Triggers the workflow on push or pull request events but only for the master branch
6-
push:
7-
branches: [master]
6+
# push:
7+
# branches: [master]
88
pull_request:
99
branches: [master]
1010
types: [opened, synchronize, reopened]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# @ngx-odm/rxdb
22

3-
> Angular 10+ wrapper for **RxDB** - A realtime Database for the Web
3+
> Angular 14+ wrapper for **RxDB** - A realtime Database for the Web
44
55
## Demo
66

7-
![Example screenshot](examples/demo/src/assets/images/screenshot.png)
7+
![Example Screencast](examples/screencast.gif)
88

99
[demo](https://voznik.github.io/ngx-odm/) - based on TodoMVC
1010

@@ -36,7 +36,7 @@ If you don't want to setup RxDB manually in your next Angular project - just imp
3636

3737
## Technologies
3838

39-
| RxDB | Angular 10+ |
39+
| RxDB | Angular 14+ |
4040
| -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
4141
| [![RxDB](https://cdn.rawgit.com/pubkey/rxdb/ba7c9b80/docs/files/logo/logo_text.svg)](https://rxdb.info/) | [![Angular](https://angular.io/assets/images/logos/angular/angular.svg)](https://angular.io/) |
4242

@@ -149,7 +149,7 @@ export class TodosService {
149149

150150
// remove many dcouments by qeury
151151
removeCompletedTodos(): void {
152-
cthis.collectionService.removeBulk({ selector: { completed: true } });
152+
this.collectionService.removeBulk({ selector: { completed: true } });
153153
}
154154
// ...
155155
}

examples/demo/src/app/todos/components/todos/todos.component.css

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/demo/src/app/todos/models/index.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/demo/src/app/todos/models/todos.model.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

examples/demo/src/app/todos/models/todos.schema.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/demo/src/app/todos/services/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/demo/src/app/todos/services/todos.service.ts

Lines changed: 0 additions & 128 deletions
This file was deleted.

examples/demo/src/app/todos/todos-routing.module.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.clear-completed:disabled {
2+
color: #999;
3+
cursor: not-allowed;
4+
text-decoration: none;
5+
}
6+
7+
.todo-list li label+.last-modified {
8+
position: absolute;
9+
bottom: 4px;
10+
right: 24px;
11+
display: none;
12+
font-size: small;
13+
color: #999;
14+
text-decoration: none !important;
15+
}
16+
17+
.todo-list li:hover label:not(.editing)+.last-modified {
18+
display: block;
19+
}

examples/demo/src/app/todos/components/todos/todos.component.html renamed to examples/demo/src/app/todos/todos.component.html

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<!-- https://angular.io/guide/template-typecheck#disabling-type-checking-using-any -->
21
<section
32
class="todoapp"
43
*ngrxLet="{
@@ -14,9 +13,8 @@ <h1>todos</h1>
1413
placeholder="What needs to be done?"
1514
autofocus=""
1615
[(ngModel)]="todosService.newTodo"
17-
(keyup)="todosService.newTodoChange($any($event.target).value)"
18-
(keyup.enter)="todosService.add()"
19-
(keyup.escape)="todosService.newTodoClear()"
16+
(keyup.enter)="todosService.addTodo()"
17+
(keyup.escape)="todosService.newTodo = ''"
2018
/>
2119
</header>
2220
<main class="main">
@@ -33,30 +31,27 @@ <h1>todos</h1>
3331
<li
3432
*ngFor="let todo of $.todos | byStatus: $.filter; trackBy: trackByFn"
3533
[class.completed]="todo.completed"
36-
[class.editing]="todosService.isEditing === todo.id"
3734
>
3835
<div class="view">
3936
<input
4037
class="toggle"
41-
[class.editing]="todosService.isEditing"
38+
[class.editing]="todosService.current?.id === todo.id"
4239
type="checkbox"
4340
[checked]="todo.completed"
44-
(change)="todosService.toggle(todo)"
41+
(change)="todosService.toggleTodo(todo)"
4542
/>
46-
<label (dblclick)="todosService.editTodo(todo, editInput)">
43+
<label
44+
[class.editing]="todosService.current?.id === todo.id"
45+
(dblclick)="todosService.setEditinigTodo(todo, $event, true)"
46+
(blur)="todosService.setEditinigTodo(todo, $event, false)"
47+
(keyup)="$event.preventDefault()"
48+
(keydown.escape)="todosService.setEditinigTodo(todo, $event, false)"
49+
(keydown.enter)="todosService.updateEditingTodo(todo, $event)"
50+
>
4751
{{ todo.title }}
4852
</label>
4953
<button class="destroy" (click)="todosService.removeTodo(todo)"></button>
5054
</div>
51-
<input
52-
class="edit"
53-
[hidden]="!todosService.isEditing"
54-
[value]="todo.title"
55-
#editInput
56-
(blur)="todosService.stopEditing()"
57-
(keyup.enter)="todosService.updateEditingTodo(todo, editInput.value)"
58-
(keyup.escape)="todosService.stopEditing()"
59-
/>
6055
</li>
6156
</ul>
6257
</main>
@@ -103,11 +98,11 @@ <h1>todos</h1>
10398
</ul>
10499
<button
105100
class="clear-completed"
106-
[disabled]="!$.todos?.length || remainig === $.todos?.length"
101+
[disabled]="!$.count || remainig === $.count"
107102
(click)="todosService.removeCompletedTodos()"
108103
style="z-index: 3"
109104
>
110-
Clear completed ({{ $.todos?.length - remainig }})
105+
Clear completed ({{ $.count - remainig }})
111106
</button>
112107
</footer>
113108
</section>

0 commit comments

Comments
 (0)