-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from filefoxper/3.2.7
## v3.2.7 2021-03-16
- Loading branch information
Showing
21 changed files
with
476 additions
and
23 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#### sharing(factory) | ||
|
||
This api function is used for generating a persistent model. [check concept](https://github.com/filefoxper/agent-reducer/blob/master/documents/en/introduction/concept.md) | ||
|
||
```typescript | ||
function sharing< | ||
S, | ||
T extends OriginAgent<S> = OriginAgent<S> | ||
>( | ||
factory:()=>T|{new ():T}, | ||
):{current:T} | ||
``` | ||
|
||
* factory - a factory callback function for generating a model(class or object) | ||
|
||
It returns a wrap object which contains a persistent model at property `current`. |
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,16 @@ | ||
#### weakSharing(factory) | ||
|
||
This api function is used for generating a weak persistent model. [check concept](https://github.com/filefoxper/agent-reducer/blob/master/documents/en/introduction/concept.md) | ||
|
||
```typescript | ||
function weakSharing< | ||
S, | ||
T extends OriginAgent<S> = OriginAgent<S> | ||
>( | ||
factory:()=>T|{new ():T}, | ||
):{current:T} | ||
``` | ||
|
||
* factory - a factory callback function for generating a model(class or object) | ||
|
||
It returns a wrap object which contains a weak persistent model at property `current`. When `Agents` from this model are all destroyed, the factory callback generates a new one. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# motivation | ||
|
||
`Reducer` is very popular in state immutable system, like `react`,`redux`. It provides a stable processing environment, and makes data flow clear. But it has troubles too, when we `dispatch an action` into a `reducer function`. We have to collect an `action` object first, and inside the `reducer function`, we need to make a distinction between each `action types (action.type)` for processing different flow. | ||
The pure functional data processor `reducer` is widely used in state immutable systems, like `react`, `redux`. It provides a stable processing environment, and makes data flow clear. But it still has space for evolution, such as the dispatching mechanism. It seems to be a good design for dispatching an action as a param to `reducer` function, but `dispatch` function is still not the `reducer` function, and `action` object is still not natural enough as function arguments. | ||
|
||
If we can use a class instance to replace `reducer`, and make calling a method as dispatching an `action`, the usage will be easy enough. Then we keep the best feature of `reducer` on, `return a next state in method` and use a class to build a `reducer`. | ||
We have made a tool working with a ES6 class processor, every method of this class processor is used for producing a next state, just like what a `reducer` does, so we call this tool `agent-reducer`. And you can consider it as a upgraded `reducer` tool. | ||
|
||
[next to concept](https://github.com/filefoxper/agent-reducer/blob/master/documents/en/introduction/concept.md) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#### sharing(factory) | ||
|
||
用于创建一个持久化共享模型。[参考概念](https://github.com/filefoxper/agent-reducer/blob/master/documents/zh/introduction/concept.md) | ||
|
||
```typescript | ||
function sharing< | ||
S, | ||
T extends OriginAgent<S> = OriginAgent<S> | ||
>( | ||
factory:()=>T|{new ():T}, | ||
):{current:T} | ||
``` | ||
|
||
* factory - 生成共享模型的工厂方法,通过该方法返回一个被共享的模型(class 或 object) | ||
|
||
该方法返回一个持久化共享模型包装,从返回值的 `current` 属性中可取出模型。 |
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,16 @@ | ||
#### weakSharing(factory) | ||
|
||
用于创建一个弱持久化共享模型。[参考概念](https://github.com/filefoxper/agent-reducer/blob/master/documents/zh/introduction/concept.md) | ||
|
||
```typescript | ||
function weakSharing< | ||
S, | ||
T extends OriginAgent<S> = OriginAgent<S> | ||
>( | ||
factory:()=>T|{new ():T}, | ||
):{current:T} | ||
``` | ||
|
||
* factory - 生成共享模型的工厂方法,通过该方法返回一个被共享的模型(class 或 object) | ||
|
||
该方法返回一个弱持久化共享模型包装,从返回值的 `current` 属性中可取出模型,当模型生成的 `Agent` 代理全被销毁时,模型会通过传入的 factory 工厂方法进行模型重置。 |
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.