mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-02-23 17:49:49 +08:00
The main idea of this patch is to set slot props to a reactive store instead of passing them as React props to the slot children elements. Same as other state management in sunmao, the component will subscribe to the slot store to get the latest value of slot props. Same as component id, we need a way to identify every slot props in the store. So we add a new parameter key to the `getSlot` function, where [component id, slot name, key] will be a unique identifier. Another challenge is to subscribe the slot store in a efficient way. Currently we are using vue's reactivity system, which need set `deep: true` to observe multiple value during effect. By setting `deep: true`, if we write code like `const $slot = slotStore[slotKey]`, it will subscribe all the sub-fields of this slot key be cause we 'access' the property. The solution is to implement a redirector Proxy. With the redirector, expression `$slot.a.b` will be redirect to `slotStore[slotKey].a.b`. related to: #388 |
||
---|---|---|
.. | ||
arco-lib | ||
chakra-ui-lib | ||
core | ||
editor | ||
editor-sdk | ||
runtime | ||
shared | ||
vite-plugin-fs | ||
vite-plugins |