This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 366
[RFC]重新设计事件 hooks #179
Labels
Comments
可以保留之前的,再加一个 |
要保留,然后显示废弃提醒。 |
class 组件呢 |
class 组件还是在 class 上直接写 |
|
TypeScript 没事吧,第一个参数用 union type,之前主要是考虑到 JavaScript 容易拼错第一个参数。 |
@yesmeck 这种方式如何 import { useEvent, OnKeyboardHeightEvent, eventType } from 'remax/alipay';
useEvent(eventType.back, () => {
console.log('back');
}); |
@LingYanSi 这样没有类型检查的话还是容易拼错。 |
|
用 ts 的话字符串也没问题的,主要是 js 。 |
那感觉这种担心是多余的,做好语法智能提示就好了。 |
用字符串,ts写好enum。然后可以在useEvent里对字符串做一次校验,不存在的抛错。 这样应该就好了 |
与其这样
为什么不直接
这样代码压缩的时候,效率不是更高吗? |
Merged
Darmody
added a commit
that referenced
this issue
Mar 18, 2020
Darmody
added a commit
that referenced
this issue
Mar 18, 2020
Darmody
added a commit
that referenced
this issue
Mar 19, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
之前把所有事件分别做成 hooks 是考虑到类型约束和避免字符串的拼错,但是现在发现支付宝小程序的事件有点多,每个事件都做成 hook 的话 API 就会有点多。
考虑把所有事件统一做到
useEvent
hook 里:支付宝小程序事件处理 https://docs.alipay.com/mini/framework/page-detail#%E9%A1%B5%E9%9D%A2%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0
The text was updated successfully, but these errors were encountered: