-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance: setResponseAction.payload -> setResponseAction.response; rem…
…ove fetchAction.payload (#3141)
- Loading branch information
Showing
28 changed files
with
225 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
'@data-client/core': minor | ||
'@data-client/react': patch | ||
'@data-client/test': patch | ||
--- | ||
|
||
BREAKING CHANGE: setResponseAction.payload -> setResponseAction.response | ||
|
||
This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that | ||
inspect `SET_RESPONSE_TYPE` `action.payload`. | ||
|
||
#### Before | ||
|
||
```ts | ||
import { SET_RESPONSE_TYPE, type Manager, type Middleware } from '@data-client/react'; | ||
|
||
export default class MyManager implements Manager { | ||
getMiddleware = (): Middleware => controller => next => async action => { | ||
switch (action.type) { | ||
case SET_RESPONSE_TYPE: | ||
console.log('Resolved with value', action.payload); | ||
return next(action); | ||
default: | ||
return next(action); | ||
} | ||
}; | ||
|
||
cleanup() {} | ||
} | ||
``` | ||
|
||
#### After | ||
|
||
```ts | ||
import { SET_RESPONSE_TYPE, type Manager, type Middleware } from '@data-client/react'; | ||
|
||
export default class MyManager implements Manager { | ||
getMiddleware = (): Middleware => controller => next => async action => { | ||
switch (action.type) { | ||
case SET_RESPONSE_TYPE: | ||
console.log('Resolved with value', action.response); | ||
return next(action); | ||
default: | ||
return next(action); | ||
} | ||
}; | ||
|
||
cleanup() {} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
'@data-client/core': minor | ||
'@data-client/react': patch | ||
'@data-client/test': patch | ||
--- | ||
|
||
BREAKING CHANGE: remove fetchAction.payload | ||
|
||
This only affects those writing custom [Managers](https://dataclient.io/docs/concepts/managers) that | ||
inspect `FETCH_TYPE` `action.fetch`. | ||
|
||
#### Before | ||
|
||
```ts | ||
import { FETCH_TYPE, type Manager, type Middleware } from '@data-client/react'; | ||
|
||
export default class MyManager implements Manager { | ||
getMiddleware = (): Middleware => controller => next => async action => { | ||
switch (action.type) { | ||
case FETCH_TYPE: | ||
// consume fetch, and print the resolution | ||
action.fetch().then(response => console.log(response)); | ||
default: | ||
return next(action); | ||
} | ||
}; | ||
|
||
cleanup() {} | ||
} | ||
``` | ||
|
||
#### After | ||
|
||
```ts | ||
import { FETCH_TYPE, type Manager, type Middleware } from '@data-client/react'; | ||
|
||
export default class MyManager implements Manager { | ||
getMiddleware = (): Middleware => controller => next => async action => { | ||
switch (action.type) { | ||
case FETCH_TYPE: | ||
// consume fetch, and print the resolution | ||
action | ||
.endpoint(...action.meta.args) | ||
.fetch() | ||
.then(response => console.log(response)); | ||
default: | ||
return next(action); | ||
} | ||
}; | ||
|
||
cleanup() {} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.