0.2.10 • Published 10 months ago
@flowgram.ai/reactive v0.2.10
Reactive
Usage
创建响应式数据并做依赖追踪
import { ReactiveState, Tracker } from '@flowgram.ai/reactive'
// 创建 数据
const reactiveState = new ReactiveState<{ a: number, b: number }>({ a: 0, b: 0 })
// 监听函数
const result = Tracker.autorun(() => {
console.log('run: ', reactiveState.value, reactiveState.value.a)
})
// 更新字典数据 a 会自动执行上边的 autorun
reactiveState.value.a = 1
// 更新数据 b 则不会执行,因为 autorun 函数里没有依赖
reactiveState.value.b = 1react 中使用
import { useReactiveState, observe } from '@flowgram.ai/reactive'
const SomeComp = ({ state }) => {
return <div>{state.a}</div>
}
function App() {
const state = useReactiveState<{ a: number, b: number }>({ a: 0, b: 0 });
useEffect(() => {
// 触发 SompeComp 更新
state.value.a = 1
// 不触发 SompeComp 更新
state.value.b = 1
})
return <SomeComp state={{state}} />
}0.2.10
10 months ago
0.2.9
10 months ago
0.1.0-alpha.9
10 months ago
0.2.8
10 months ago
0.2.7
10 months ago
0.1.0-alpha.8
10 months ago
0.2.6
10 months ago
0.2.5
10 months ago
0.2.4
10 months ago
0.2.3
10 months ago
0.2.2
10 months ago
0.2.1
10 months ago
0.2.0
10 months ago
0.1.31
10 months ago
0.1.30
10 months ago
0.1.29
10 months ago
0.1.28
11 months ago
0.1.27
11 months ago
0.1.26
11 months ago
0.1.25
11 months ago
0.1.24
11 months ago
0.1.0-alpha.7
11 months ago
0.1.23
11 months ago
0.1.22
12 months ago
0.1.0-alpha.6
12 months ago
0.1.21
12 months ago
0.1.18
12 months ago
0.1.17
12 months ago
0.1.16
12 months ago
0.1.15
1 year ago
0.1.0-alpha.5
1 year ago
0.1.14
1 year ago
0.1.0-alpha.4
1 year ago
0.1.13
1 year ago
0.1.0-alpha.3
1 year ago
0.1.0-alpha.2
1 year ago
0.1.12
1 year ago
0.1.11
1 year ago
0.1.10
1 year ago
0.1.9
1 year ago
0.1.8
1 year ago
0.1.0
1 year ago
0.1.7
1 year ago
0.1.6
1 year ago
0.1.5
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago