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

拦截器 #2

Closed
DestinyHunter opened this issue Jan 19, 2019 · 8 comments
Closed

拦截器 #2

DestinyHunter opened this issue Jan 19, 2019 · 8 comments
Assignees

Comments

@DestinyHunter
Copy link

应该支持拦截器.比较方便多地方用同样参数的方法.

@elcarim5efil
Copy link

想要的效果是怎样的?是每个 api 一个拦截器吗?

@DestinyHunter
Copy link
Author

每个都有当然更好了..不过获取设备信息之类的拦截器好像没啥用.但是像关于视图和请求的就有必要了像.request,upload, showModal .showtoast 之类的

@elcarim5efil
Copy link

elcarim5efil commented Jan 22, 2019

showModal 的拦截器是想类似这么用?

Megalo.showToast.params.use(({ message, duration = 1000 }) => {
       return {
          message: `wrap [${message}]`,
          duration,
       }
})

@DestinyHunter
Copy link
Author

对.在方法使用之前或者之后又公共的处理,,,
https://github.com/bigmeow/minapp-api-promise 这里的拦截器那样

@elcarim5efil
Copy link

其实就是加 aop 模式,before,after。

@DestinyHunter
Copy link
Author

嗯. 有这样的需求.before 传入token ,加上loading, 改变颜色什么的.一次就行.不然每次用的时候都需要传入重复的值

@geminate
Copy link

其实可以考虑写一个全局方法,调用的时候用自己的全局方法

zhuping pushed a commit that referenced this issue Mar 13, 2019
zhuping added a commit that referenced this issue Mar 13, 2019
@zhuping
Copy link
Collaborator

zhuping commented Mar 13, 2019

have supported request interceptors #12

@zhuping zhuping closed this as completed Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants