@@ -58,11 +58,9 @@ export const Todo = Component.make(function* Todo(props: TodoProps) {
|
|||||||
onClick={() => Runtime.runSync(runtime)(
|
onClick={() => Runtime.runSync(runtime)(
|
||||||
SubscriptionRef.updateEffect(state.ref, todos => Effect.gen(function*() {
|
SubscriptionRef.updateEffect(state.ref, todos => Effect.gen(function*() {
|
||||||
if (props.index <= 0) return yield* Option.none()
|
if (props.index <= 0) return yield* Option.none()
|
||||||
const toSwapIndex = props.index - 1
|
|
||||||
const toSwap = yield* Chunk.get(todos, toSwapIndex)
|
|
||||||
return todos.pipe(
|
return todos.pipe(
|
||||||
Chunk.replace(props.index, toSwap),
|
Chunk.replace(props.index, yield* Chunk.get(todos, props.index - 1)),
|
||||||
Chunk.replace(toSwapIndex, yield* ref),
|
Chunk.replace(props.index - 1, yield* ref),
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
)}
|
)}
|
||||||
@@ -75,11 +73,9 @@ export const Todo = Component.make(function* Todo(props: TodoProps) {
|
|||||||
onClick={() => Runtime.runSync(runtime)(
|
onClick={() => Runtime.runSync(runtime)(
|
||||||
SubscriptionRef.updateEffect(state.ref, todos => Effect.gen(function*() {
|
SubscriptionRef.updateEffect(state.ref, todos => Effect.gen(function*() {
|
||||||
if (props.index >= size - 1) return yield* Option.none()
|
if (props.index >= size - 1) return yield* Option.none()
|
||||||
const toSwapIndex = props.index + 1
|
|
||||||
const toSwap = yield* Chunk.get(todos, toSwapIndex)
|
|
||||||
return todos.pipe(
|
return todos.pipe(
|
||||||
Chunk.replace(props.index, toSwap),
|
Chunk.replace(props.index, yield* Chunk.get(todos, props.index + 1)),
|
||||||
Chunk.replace(toSwapIndex, yield* ref),
|
Chunk.replace(props.index + 1, yield* ref),
|
||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user