Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Reactive statements and declarations #3

Open
TheRandomMelon opened this issue Sep 20, 2021 · 1 comment
Open

Reactive statements and declarations #3

TheRandomMelon opened this issue Sep 20, 2021 · 1 comment
Assignees
Labels
compiler Things related to the compiler. enhancement New feature or request
Milestone

Comments

@TheRandomMelon
Copy link
Member

TheRandomMelon commented Sep 20, 2021

Statements (conditionals)

// What the user types
$: if (test > 10 && color.get() !== color.get_last()) {
    color.set('color: green');
}

// What the compiler outputs to JS
test.subscribe((new_val, old_val) => {
    if (new_val > 10 && color.get() !== color.get_last()) {
        color.set('color: green');
    }
})

Declarations

// What the user types
$: is_greater_than = test > 30;

// What the compiler outputs to JS
let is_greater_than = variable(test > 30);
test.subscribe((new_val, old_val) => {
    is_greater_than.set(test > 30);
})
@TheRandomMelon TheRandomMelon added the enhancement New feature or request label Sep 20, 2021
@TheRandomMelon TheRandomMelon added this to the Compiler milestone Sep 20, 2021
@TheRandomMelon TheRandomMelon changed the title Reactive statements and declarations Reactive declarations Sep 20, 2021
@TheRandomMelon TheRandomMelon changed the title Reactive declarations Reactive statements Sep 20, 2021
@TheRandomMelon TheRandomMelon changed the title Reactive statements Reactive statements and declarations Sep 20, 2021
@TheRandomMelon
Copy link
Member Author

Wow, finally got this worded right.

@TheRandomMelon TheRandomMelon added the compiler Things related to the compiler. label Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler Things related to the compiler. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants