Skip to content
Discussion options

You must be logged in to vote

Thanks @gbj, these are all great solutions.

To scratch my itch, I've figured out a somewhat inelegant solution that seems to work fine:

/// Wrap a field with a signal that's only updated when the field is updated from an external source and a set function to do that.
pub fn one_way_field_update<T>(field: Field<T>) -> (ReadSignal<T>, impl Fn(T) + Copy + 'static)
where
    T: Clone + Send + Sync + 'static,
{
    // Whether the value is updated internally or externally
    let is_internal_update = StoredValue::new(false);

    // Internal shadow copy of the external value
    let (external_only, set_external_only) = signal(field.get_untracked());

    // Update the internal value when the ex…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tversteeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants