Skip to content

Commit a63e01a

Browse files
BioPhotonedbzneneajahohoebbelsB
authored
feat(state): introduce RxActions
* perf: introduce actions * refactor: implemented updates from @nartc * refactor: implemented transforms * docs: initial docs * docs: initial api docs * docs: initial api docs * fix: typing * test: implement basic tests * test: adopt tests for getActions * fix: typing of ActionAccess * refactor: complete refactoring of types * refactor: progress * refactor: refactor to class and creation function * refactor: make transforms optional * refactor: fix functionality * test: test service * docs: update code examples * refactor: move actions into state * fix: destroy in creator function * fix: tests * fix: lint errors * fix: merge * fix: actions typings fix from move * Update libs/state/actions/README.md * Update libs/state/actions/README.md * Update Readme.md * Update actions.factory.spec.ts * Update actions.factory.ts * Update proxy.ts * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update libs/state/actions/docs/Readme.md * Update libs/state/actions/docs/Readme.md Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> * Update Readme.md * Update libs/state/actions/docs/Readme.md Co-authored-by: Enea Jahollari <jahollarienea14@gmail.com> * Update libs/state/actions/src/lib/actions.factory.ts Co-authored-by: Enea Jahollari <jahollarienea14@gmail.com> * Update libs/state/actions/src/lib/actions.factory.ts Co-authored-by: Enea Jahollari <jahollarienea14@gmail.com> * feat: add actions to demos * fix: add error handling * feat: add transforms and multi signal selection * fix: maintain subjects per create call * test: test subjects per create call * fix: typings * fix: typings * fix: typings * fix: typings * fix: typings * fix: typings * fix: typings Co-authored-by: Edouard Bozon <bozonedouard@gmail.com> Co-authored-by: Enea Jahollari <jahollarienea14@gmail.com> Co-authored-by: Julian Jandl <julian@jandl.wien>
1 parent 1068b7c commit a63e01a

File tree

13 files changed

+856
-6
lines changed

13 files changed

+856
-6
lines changed

apps/demos/src/app/features/concepts/projected-views/projected-views.component.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { combineLatest, Subject } from 'rxjs';
88
import { ContentChildComponent } from './content-child.component';
99
import { ViewChildComponent } from './view-child.component';
10+
import { RxActionFactory } from '@rx-angular/state/actions';
1011

1112
@Component({
1213
selector: 'rxa-projected-views',
@@ -17,7 +18,7 @@ import { ViewChildComponent } from './view-child.component';
1718
<button
1819
mat-raised-button
1920
[unpatch]="['click']"
20-
(click)="trigger$.next($event.timeStamp)"
21+
(click)="ui.trigger($event.timeStamp)"
2122
>
2223
tick
2324
</button>
@@ -26,16 +27,31 @@ import { ViewChildComponent } from './view-child.component';
2627
test1
2728
<rxa-view-child>
2829
<div>
29-
<div *rxLet="renderCallback$; let renderCbVal; parent: false; patchZone: false">
30+
<div
31+
*rxLet="
32+
renderCallback$;
33+
let renderCbVal;
34+
parent: false;
35+
patchZone: false
36+
"
37+
>
3038
renderCallback: {{ renderCbVal }}
3139
</div>
32-
<div *rxLet="trigger$; renderCallback: renderCallback$;let value; parent: true; patchZone: false">
40+
<div
41+
*rxLet="
42+
ui.trigger$;
43+
renderCallback: renderCallback$;
44+
let value;
45+
parent: true;
46+
patchZone: false
47+
"
48+
>
3349
<rxa-content-child>
3450
<div #test>{{ value }}</div>
3551
</rxa-content-child>
3652
</div>
3753
<!--
38-
<div *rxFor="trigger$; let value; parent: true">
54+
<div *rxFor="ui.trigger$; let value; parent: true">
3955
<rxa-content-child>
4056
<div #test>{{ value }}</div>
4157
</rxa-content-child>
@@ -46,6 +62,7 @@ import { ViewChildComponent } from './view-child.component';
4662
</rxa-visualizer>
4763
`,
4864
changeDetection: ChangeDetectionStrategy.OnPush,
65+
providers: [RxActionFactory],
4966
})
5067
export class ProjectedViewsComponent {
5168
@ViewChildren('test') set test(t) {
@@ -68,8 +85,10 @@ export class ProjectedViewsComponent {
6885
);
6986
}
7087

71-
trigger$ = new Subject<any>();
88+
constructor(private actions: RxActionFactory<{ trigger: number }>) {}
89+
90+
ui = this.actions.create();
7291
renderCallback$ = new Subject<any>();
7392

74-
triggerArr$ = combineLatest([this.trigger$]);
93+
triggerArr$ = combineLatest([this.ui.trigger$]);
7594
}

libs/state/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RxState is a lightweight, flexible, strongly typed and tested tool dedicated to
1414

1515
- [🧩 Selections](https://github.com/rx-angular/rx-angular/blob/main/libs/state/selections/README.md)
1616
- [☁ Effects](https://github.com/rx-angular/rx-angular/blob/main/libs/state/effects/README.md)
17+
- [? Actions](https://github.com/rx-angular/rx-angular/blob/main/libs/state/actions/README.md)
1718

1819
## Intro Video
1920

libs/state/actions/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# @rx-angular/state/actions
2+
3+
[![npm](https://img.shields.io/npm/v/%40rx-angular%2Fstate.svg)](https://www.npmjs.com/package/%40rx-angular%2Fstate)
4+
![rx-angular CI](https://github.com/rx-angular/rx-angular/workflows/rx-angular%20CI/badge.svg?branch=master)
5+
[![Coverage Status](https://raw.githubusercontent.com/rx-angular/rx-angular/github-pages/docs/test-coverage/state/jest-coverage-badge.svg)](https://rx-angular.github.io/rx-angular/test-coverage/state/lcov-report/index.html)
6+
7+
## This package provides a quick way to create an action channel and some configuration options.
8+
9+
10+
## Key features
11+
12+
- ✅ Fully Typed
13+
- ✅ No-Boilerplate
14+
- ✅ Configurable transformations to have lines in the template
15+
- ✅ Minimal memory footprint through a Proxy object and lazy initialization
16+
17+
## Demos:
18+
19+
- [⚡ GitHub](https://github.com/BioPhoton/rx-angular-state-actions)
20+
21+
## Install
22+
23+
```bash
24+
npm install --save @rx-angular/state
25+
# or
26+
yarn add @rx-angular/state

0 commit comments

Comments
 (0)