Skip to content

fluid effect not re-running when it should #3

Description

@trusktr

Check out this example:

import {state, effect, memo} from '@fluid/core'

const count1 = state(0)
setInterval(() => count1.val++, 1000)

const count2 = state(0)
setInterval(() => count2.val++, 100)

const bool = state(true)
setInterval(() => bool.val = !bool.val, 2000)

console.log('start ----------------------------- ')

effect(() => {
	if (bool.val) {
		count1.val
		console.log('a')		
	} else {
		count2.val
		console.log('b')
	}
})

When the conditional branch changes to the false side, count2 should be the new dependency triggering the effect.

CodePen:

https://codepen.io/trusktr/pen/KwPjOWo/ea2c637ac0b6661ff4fbe6458984a338

The Solid.js version shows the expected behavior:

https://codepen.io/trusktr/pen/qEWzePW/3cd3eb4ea0e34551a597c9d3b08047c4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions