Skip to content

Commit

Permalink
Merge ceaa3e4 into b566ce0
Browse files Browse the repository at this point in the history
  • Loading branch information
albertleigh committed Mar 3, 2021
2 parents b566ce0 + ceaa3e4 commit 5a07cca
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 41 deletions.
2 changes: 1 addition & 1 deletion examples/ng-sample-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/ng-sample-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng-sample-app",
"version": "0.0.7",
"version": "0.0.8",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand All @@ -22,11 +22,11 @@
"@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0",
"redux": "^4.0.5",
"redux-anno": "^0.0.7",
"redux-anno-utils": "^0.0.7",
"redux-anno": "^0.0.8",
"redux-anno-utils": "^0.0.8",
"redux-saga": "^1.1.3",
"rxjs": "~6.6.0",
"sample-shared-models": "^0.0.7",
"sample-shared-models": "^0.0.8",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react-sample-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/react-sample-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-sample-app",
"version": "0.0.7",
"version": "0.0.8",
"private": true,
"homepage": ".",
"dependencies": {
Expand All @@ -22,10 +22,10 @@
"react-redux": "^7.2.2",
"react-scripts": "^4.0.2",
"redux": "^4.0.5",
"redux-anno": "^0.0.7",
"redux-anno-utils": "^0.0.7",
"redux-anno": "^0.0.8",
"redux-anno-utils": "^0.0.8",
"redux-saga": "^1.1.3",
"sample-shared-models": "^0.0.7",
"sample-shared-models": "^0.0.8",
"typescript": "^4.1.5"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/sample-shared-models/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/sample-shared-models/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "sample-shared-models",
"private": true,
"version": "0.0.7",
"version": "0.0.8",
"description": "",
"type": "module",
"main": "lib/index.js",
"dependencies": {
"redux-anno": "^0.0.7",
"redux-anno-utils": "^0.0.7",
"redux-anno": "^0.0.8",
"redux-anno-utils": "^0.0.8",
"redux-saga": "^1.1.3",
"typescript": "^4.0.3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/vue-sample-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions examples/vue-sample-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-sample-app",
"version": "0.0.7",
"version": "0.0.8",
"private": true,
"scripts": {
"start": "vue-cli-service serve",
Expand All @@ -11,11 +11,11 @@
"ant-design-vue": "^2.0.0-beta.10",
"core-js": "^3.6.5",
"redux": "^4.0.5",
"redux-anno": "^0.0.7",
"redux-anno-utils": "^0.0.7",
"redux-anno": "^0.0.8",
"redux-anno-utils": "^0.0.8",
"redux-saga": "^1.1.3",
"redux-vuex": "^3.0.0-beta.2",
"sample-shared-models": "^0.0.7",
"sample-shared-models": "^0.0.8",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0"
},
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.7",
"version": "0.0.8",
"packages": [
"packages/*",
"examples/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-anno",
"version": "0.0.7",
"version": "0.0.8",
"description": "A middleware leverages certain boilerplate while using redux",
"scripts": {
"clean": "node ./scripts/clean.js",
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ import {AnyClass, KeysOfType, prePopulateMapFieldViaPrototype, Proto} from './ut
export type SagaField<TPayload = any, TResult = any> =
| ((payload: TPayload) => Generator<StrictEffect | any, TResult>)
| (() => Generator<StrictEffect | any, TResult>);
export type ExtractSagaFieldPayload<T> = T extends () => Generator
? undefined
: T extends (payload: infer _TPayload) => Generator
? _TPayload
: undefined;
export type ExtractSagaFieldPayload<T> = T extends (...args: infer _APayload) => Generator ? _APayload[0] : never;
export type ExtractSagaFieldResult<T> = T extends
| ((payload: any) => Generator<any, infer _TResult>)
| (() => Generator<any, infer _TResult>)
Expand Down
7 changes: 1 addition & 6 deletions packages/core/src/thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ import {ActionHelper, implementActionHelper} from './action';
export type ThunkField<TPayload = any, TResult = any> =
| ((payload: TPayload) => Promise<TResult>)
| (() => Promise<TResult>);
export type ExtractThunkFieldPayload<T> = T extends () => Promise<any>
? undefined
: T extends (payload: infer _TPayload) => Promise<any>
? _TPayload
: undefined;

export type ExtractThunkFieldPayload<T> = T extends (...args: infer _APayload) => Promise<any> ? _APayload[0] : never;
export type ExtractThunkFieldResult<T> = T extends
| ((payload: any) => Promise<infer _TResult>)
| (() => Promise<infer _TResult>)
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-anno-utils",
"version": "0.0.7",
"version": "0.0.8",
"description": "Utils package for redux-anno",
"keywords": [
"redux-anno"
Expand All @@ -23,7 +23,7 @@
"author": "Wentao LI",
"license": "MIT",
"dependencies": {
"redux-anno": "^0.0.7"
"redux-anno": "^0.0.8"
},
"optionalDependencies": {
"react": "^16.13.1"
Expand Down
22 changes: 18 additions & 4 deletions packages/utils/src/sdk-helpers/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ export interface Client<T> {
[P in keyof T]: T[P] extends StateField<infer S>
? ValueEventEmitter<S>
: T[P] extends ThunkField
? (payload: ExtractThunkFieldPayload<T[P]>) => Promise<ExtractThunkFieldResult<T[P]>>
? NonNullable<ExtractThunkFieldPayload<T[P]>> extends never
? () => Promise<ExtractThunkFieldResult<T[P]>>
: ExtractThunkFieldPayload<T[P]> & undefined extends never
? (payload: ExtractThunkFieldPayload<T[P]>) => Promise<ExtractThunkFieldResult<T[P]>>
: (payload?: NonNullable<ExtractThunkFieldPayload<T[P]>>) => Promise<ExtractThunkFieldResult<T[P]>>
: T[P] extends SagaField
? (payload: ExtractSagaFieldPayload<T[P]>) => Promise<ExtractSagaFieldResult<T[P]>>
? NonNullable<ExtractSagaFieldPayload<T[P]>> extends never
? () => Promise<ExtractSagaFieldResult<T[P]>>
: ExtractSagaFieldPayload<T[P]> & undefined extends never
? (payload: ExtractSagaFieldPayload<T[P]>) => Promise<ExtractSagaFieldResult<T[P]>>
: (payload?: NonNullable<ExtractSagaFieldPayload<T[P]>>) => Promise<ExtractSagaFieldResult<T[P]>>
: T[P] extends ComputedField<infer C>
? ValueEventEmitter<C>
: T[P] extends IsAnnoReducerField
? (payload: ExtractReducerFieldPayload<T[P]>) => Promise<void>
? NonNullable<ExtractReducerFieldPayload<T[P]>> extends undefined
? () => Promise<void>
: ExtractReducerFieldPayload<T[P]> & undefined extends never
? (payload: ExtractReducerFieldPayload<T[P]>) => Promise<void>
: (payload?: NonNullable<ExtractReducerFieldPayload<T[P]>>) => Promise<void>
: unknown;
};
close(): void;
Expand Down Expand Up @@ -148,7 +160,9 @@ export function createClient<T>(option: ClientOption): Client<T> {
// partial populate all those event emitters
Object.keys(msg.partialState).forEach((field) => {
if (field in result.instance) {
(result.instance as any)[field].emit(msg.partialState[field]);
const rawValue = msg.partialState[field];
const nextValue = rawValue === UNDEFINED_SYMBOL ? undefined : rawValue;
(result.instance as any)[field].emit(nextValue);
}
});
clientProtImpl.ack(msg);
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/src/sdk-helpers/createDelegator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ export function createDelegator(option: DelegatorOption) {
let needToUpdate = false;
for (const field of fields) {
if (lastState[field] !== theInst[field].value) {
partialState[field] = theInst[field].value;
const theValue = theInst[field].value;
partialState[field] = theValue === undefined || theValue === null ? UNDEFINED_SYMBOL : theValue;
needToUpdate = true;
}
}
Expand Down

0 comments on commit 5a07cca

Please sign in to comment.