Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RESTful 结合 DDD 前端方案 #2

Open
inJs opened this issue Apr 28, 2019 · 6 comments
Open

RESTful 结合 DDD 前端方案 #2

inJs opened this issue Apr 28, 2019 · 6 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@inJs
Copy link
Member

inJs commented Apr 28, 2019

加强设计环节,推荐前端领域建模。更好的方式应该放置于 BFF 层, 缺点是门槛较高。

@inJs inJs added the good first issue Good for newcomers label Apr 28, 2019
@inJs inJs self-assigned this Apr 28, 2019
@inJs
Copy link
Member Author

inJs commented Apr 29, 2019

如何避免 在 reducer 中解构 Model 导致其丧失类型?

@inJs
Copy link
Member Author

inJs commented Apr 29, 2019

具象 Model 与 pathname 一一对应,请求成功即创建 具象 Model 实例

@inJs
Copy link
Member Author

inJs commented Apr 30, 2019

目前期望能达到的效果:(伪代码)

const requestEngine = restfulify<UserModel>({ api: '/user' ...others})
const user: UserModel = requestEngine.select().relate(UserModel) // allow

const requestEngine = restfulify<UserModel>({ api: '/user/list' ...others})

const users: UserModel[] = requestEngine.select().relate(UserModel).arraying()

@inJs
Copy link
Member Author

inJs commented Apr 30, 2019

请求库 需要开放 config 配置以适配各种场景

@inJs
Copy link
Member Author

inJs commented May 8, 2019

Model 增加更新模型字段的方法, 同时以 范型 约束类型,避免因 解构 导致类型丢失。范式:

const user = new User()

const newUser = user.patch({ avatar, name, tel }) // 仍然返回 User 的实例

@inJs
Copy link
Member Author

inJs commented May 8, 2019

Model 需要开放 构造函数参数 以决定对应的 实例是否开启空值保护(null、undefined)。 是否可以自定义规则???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant