Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[IDEA] create a "change-catcher" widget, which allows us to create wikitext-actions based on the core change event #8113

Closed
pmario opened this issue Mar 28, 2024 · 5 comments

Comments

@pmario
Copy link
Contributor

pmario commented Mar 28, 2024

Just a reminder, so it is not forgotten.

See: https://talk.tiddlywiki.org/t/idea-cascades-for-save-button-close-button-edit-button-etc/9327/14?u=pmario

and my response: https://talk.tiddlywiki.org/t/idea-cascades-for-save-button-close-button-edit-button-etc/9327/15?u=pmario

But this means that my idea of lifecycle events no longer sounds particularly far-fetched. There’s a mechanism in the underlying JS, which we should (presumably?) be able to expose to wikitext, to tap into certain lifecycle events.

The “change” event is activated, whenever a tiddler changes in the tiddler store. It activates all event-listeners, that are registered to listen to it. Usually the change event triggers the widgets “refresh” mechanism. Within widgets, there is a lot of logic going on, to only trigger a child-refresh, if it is really needed. So if widget parameters are not “connected” to the tiddlers that are changed, there is no refresh needed. …

If we expose the change event to eg: wikitext actions, it’s very likely that users will start to modify tiddler content based on this event. That will cause a “change” event, which triggers the actions, which causes a “change” event, which triggers the actions, which causes … you get the idea … The perfect environment to brick the wiki and loose data.

So we basically would need a <$change-catcher widget, which must define a filter parameter that limits the tiddlers, the catcher is bound to. So we can make it safer to use. The change-catcher widget would only be active, if it is visible and imo it should ignore its body text. So it would look like <$change-catcher filter="[tag[x]]" actions=<<actions>>/>

@Jermolene
Copy link
Owner

Hi @pmario from the original context, it really sounds like the underlying problem that people are trying to solve is forcing refresh of content that doesn't automatically refresh. I suspect that we'd be better off exploring fixes for that specific problem than opening this particular can of worms: besides the usability issues you correctly identified, there are also quite a few implementation issues. For example, this implies that a widget could listen to tiddler store events, which would mean cleaning up the listener when the widget is removed, which is not currently supported. Of course, widgets already indirectly get passed change events in the shape of the refresh method, which takes us back to my suggestion that we fix the refresh process.

It seems much simpler to have something like a new widget that always re-renders its content at every refresh.

@CodaCodr
Copy link
Contributor

Unless I'm missing something about the proposal...

I monitor change events using $eventcatcher. Works fine as is.

Is there a nuance here I'm not aware of?

@pmario
Copy link
Contributor Author

pmario commented Mar 28, 2024

I monitor change events using $eventcatcher. Works fine as is.

Do you have a code example for this one? I thought the eventcatcher can only catch events initiated by users.

The idea should make the core wiki "change-event" available to wikitext. -- If possible -- Some experiments would be needed.

@CodaCodr
Copy link
Contributor

Do you have a code example for this one? I thought the eventcatcher can only catch events initiated by users.

Ah, that's the nuance I was missing. As you were ;)

@pmario
Copy link
Contributor Author

pmario commented Mar 29, 2024

@Jermolene -- Can you make this issue a Discussion. So I do not need to close it and give us more time to think about it.

Repository owner locked and limited conversation to collaborators Mar 29, 2024
@Jermolene Jermolene converted this issue into discussion #8119 Mar 29, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants