Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WISH: finer control over reactive relations triggered by pairs #77

Open
hiiamboris opened this issue May 30, 2020 · 3 comments
Open

WISH: finer control over reactive relations triggered by pairs #77

hiiamboris opened this issue May 30, 2020 · 3 comments

Comments

@hiiamboris
Copy link

hiiamboris commented May 30, 2020

I find it often a case where a reaction should be only placed on x or y coordinate of face's offset, size or custom pair dimension.

However, reactivity does not provide this flexibility: place a reaction on /x and it will be triggered by a change in /y. (Not just reactivity, on-deep-change does not provide this info either)

Not only this produces unneeded reactions, but also prevents one from creating flexible resize scenarios, e.g. what if I want to set /y to a default, but only if it wasn't explicitly set to another value?

default: 10
r: deep-reactor [
    s: 1x1
    react [
        [self/s/x]                          ;) s/x serves as a reaction source
        triggered-by-SX: yes                ;) NO WAY TO KNOW THIS!!
        if triggered-by-SX [s/y: default]   ;) otherwise I wanna leave s/y as is - how?
        ?? s
    ]
]
r/s/x: 2
r/s/y: 3

Output:

s: 1x10
s: 2x10
s: 2x10        ;) I want 2x3 here
@dockimbel
Copy link
Member

After the changes made by on-deep-fixes branch, pair individual component setting will trigger a on-change reaction (and no more on-deep-change). That was necessary as the deep change handler is really meant for series. OTOH, the value change handler spec does not allow to pass the information about which component was changed. So I think that the on-change spec should be extended to pass the value's component name, when applicable.

@hiiamboris
Copy link
Author

Like on-change [subject [word! path!] old [any-type!] new [any-type!]] ?

@dockimbel
Copy link
Member

That's one option, another one is just to add an extra field [word! none!] argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants