Skip to content

Commit 21f2bea

Browse files
authored
Merge branch 'main' into test/make-rx-for-stable
2 parents 135308c + 52904fb commit 21f2bea

File tree

7 files changed

+53
-32
lines changed

7 files changed

+53
-32
lines changed

libs/cdk/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
44

5+
# [1.0.0-rc.0](https://github.com/rx-angular/rx-angular/compare/cdk@1.0.0-beta.3...cdk@1.0.0-rc.0) (2022-08-28)
6+
7+
8+
### Features
9+
10+
* **cdk:** deprecate global StrategyCredentials and replace with native ([#1389](https://github.com/rx-angular/rx-angular/issues/1389)) ([f46e837](https://github.com/rx-angular/rx-angular/commit/f46e837137cefd2753b331c0bb3d249aa286905b))
11+
12+
13+
514
# [1.0.0-beta.3](https://github.com/rx-angular/rx-angular/compare/cdk@1.0.0-beta.2...cdk@1.0.0-beta.3) (2022-06-07)
615

716

libs/cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rx-angular/cdk",
3-
"version": "1.0.0-beta.3",
3+
"version": "1.0.0-rc.0",
44
"description": "@rx-angular/cdk is a Component Development Kit for ergonomic and highly performant angular applications. It helps to to build Large scale applications, UI libs, state management, rendering systems and much more. Furthermore the unique way of mixing reactive as well as imperative code leads to best DX and speed.",
55
"main": "index.js",
66
"publishConfig": {

libs/cdk/render-strategies/docs/basic-strategies.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ In combination with Observables, and EmbeddedViews change detection can be speed
8181

8282
### Strategies
8383

84-
| Name | Priority | Render Method | Scheduling | Render Deadline |
85-
| ---------- | -------- | ----------------- | ----------------------- | --------------- |
86-
| `"native"` ||`markForCheck` | `requestAnimationFrame` | N/A |
87-
| `"global"` ||`ɵmarkDirty` | `requestAnimationFrame` | N/A |
88-
| `"local"` || 🠗 `detectChanges` | `requestAnimationFrame` | N/A |
89-
| `"noop"` || - `noop` | `requestAnimationFrame` | N/A |
84+
| Name | Priority | Render Method | Scheduling | Render Deadline |
85+
|-------------------------| -------- | ----------------- | ----------------------- | --------------- |
86+
| `"native"` ||`markForCheck` | `requestAnimationFrame` | N/A |
87+
| `"global"` - _deprecated_ ||`ɵmarkDirty` | `requestAnimationFrame` | N/A |
88+
| `"local"` || 🠗 `detectChanges` | `requestAnimationFrame` | N/A |
89+
| `"noop"` || - `noop` | `requestAnimationFrame` | N/A |
9090

9191
#### Native
9292

@@ -103,6 +103,9 @@ as the internally called function [`markViewDirty`](https://github.com/angular/a
103103

104104
#### Global Strategy
105105

106+
> **deprecated**
107+
> angular [drops support](https://github.com/angular/angular/pull/46806) for `ɵmarkDirty`
108+
106109
This strategy leverages Angular's internal [`ɵmarkDirty`](https://github.com/angular/angular/blob/930eeaf177a4c277f437f42314605ff8dc56fc82/packages/core/src/render3/instructions/change_detection.ts#L36) render method.
107110
It acts identical to [`ChangeDetectorRef#markForCheck`](https://github.com/angular/angular/blob/930eeaf177a4c277f437f42314605ff8dc56fc82/packages/core/src/render3/view_ref.ts#L128) but works also 🚫 zone-less.
108111
`markDirty` in comparison to `markForCheck` also calls [`scheduleTick`](https://github.com/angular/angular/blob/930eeaf177a4c277f437f42314605ff8dc56fc82/packages/core/src/render3/instructions/shared.ts#L1863) which is the reason why it also works in 🚫 zone-less environments.

libs/cdk/render-strategies/src/lib/model.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ export type RxCustomStrategyCredentials<T extends string> = Record<
3030
T,
3131
RxStrategyCredentials
3232
>;
33-
export type RxNativeStrategyNames = 'native' | 'local' | 'global' | 'noop';
33+
/**
34+
* @deprecated
35+
* angular drops the internal markDirty API, will fall back to native if used
36+
*/
37+
export type RxGlobalStrategyName = 'global';
38+
export type RxNativeStrategyNames =
39+
| 'native'
40+
| 'local'
41+
| 'noop'
42+
| RxGlobalStrategyName;
3443
export type RxConcurrentStrategyNames =
3544
| 'immediate'
3645
| 'userBlocking'

libs/cdk/render-strategies/src/lib/native-strategies.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ɵmarkDirty as markDirty } from '@angular/core';
1+
import { NgZone } from '@angular/core';
22
import { Observable } from 'rxjs';
33
import { tap } from 'rxjs/operators';
44
import { coalesceWith } from '@rx-angular/cdk/coalescing';
@@ -36,15 +36,6 @@ const localCredentials: RxStrategyCredentials = {
3636
),
3737
};
3838

39-
const globalCredentials: RxStrategyCredentials = {
40-
name: 'global',
41-
work: (_, context) => markDirty(context),
42-
behavior:
43-
({ work, ngZone }) =>
44-
(o$) =>
45-
o$.pipe(tap(() => (ngZone ? ngZone.run(() => work()) : work()))),
46-
};
47-
4839
const noopCredentials: RxStrategyCredentials = {
4940
name: 'noop',
5041
work: () => void 0,
@@ -57,7 +48,22 @@ const nativeCredentials: RxStrategyCredentials = {
5748
behavior:
5849
({ work, ngZone }) =>
5950
(o$) =>
60-
o$.pipe(tap(() => (ngZone ? ngZone.run(() => work()) : work()))),
51+
o$.pipe(
52+
tap(() =>
53+
ngZone && !NgZone.isInAngularZone()
54+
? ngZone.run(() => work())
55+
: work()
56+
)
57+
),
58+
};
59+
60+
/**
61+
* @deprecated
62+
* angular drops the internal markDirty API, will fall back to native if used
63+
*/
64+
const globalCredentials: RxStrategyCredentials = {
65+
...nativeCredentials,
66+
name: 'global',
6167
};
6268

6369
export type RxNativeStrategies =

libs/cdk/render-strategies/src/lib/onStrategy.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgZone } from '@angular/core';
22
import { RxCoalescingOptions } from '@rx-angular/cdk/coalescing';
3-
import { switchMap, take } from 'rxjs/operators';
4-
import { Observable, of, throwError } from 'rxjs';
3+
import { Observable, throwError } from 'rxjs';
4+
import { catchError, map, take } from 'rxjs/operators';
55
import { RxRenderWork, RxStrategyCredentials } from './model';
66

77
/**
@@ -22,22 +22,16 @@ export function onStrategy<T>(
2222
) => void,
2323
options: RxCoalescingOptions & { ngZone?: NgZone } = {}
2424
): Observable<T> {
25-
let error: Error;
2625
return new Observable<T>((subscriber) => {
2726
subscriber.next(value);
2827
}).pipe(
2928
strategy.behavior({
30-
work: () => {
31-
try {
32-
workFactory(value, strategy.work, options);
33-
} catch (e) {
34-
error = e;
35-
}
36-
},
29+
work: () => workFactory(value, strategy.work, options),
3730
scope: (options.scope as Record<string, unknown>) || {},
3831
ngZone: options.ngZone,
3932
}),
40-
switchMap(() => (error ? throwError([error, value]) : of(value))),
33+
catchError((error) => throwError(() => [error, value])),
34+
map(() => value),
4135
take(1)
4236
);
4337
}

libs/state/effects/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
## Demos:
2222

23-
- [⚡ GitHub](https://github.com/BioPhoton/rx-angular-state-effects)
23+
- [⚡ GitHub](https://github.com/rx-angular/rx-angular/tree/main/apps/demos/src/app/features/tutorials/basics/5-side-effects)
2424

2525

2626
## Install
@@ -44,5 +44,5 @@ nx migrate @rx-angular/state
4444

4545
## Documentation
4646

47-
- [RxEffects]()
47+
- [RxEffects](https://github.com/rx-angular/rx-angular/tree/main/libs/state/effects/docs)
4848

0 commit comments

Comments
 (0)