Skip to content

Event/event-core refactor#1486

Closed
RedRafe wants to merge 1 commit intoRefactorio:developfrom
RedRafe:event-refactor
Closed

Event/event-core refactor#1486
RedRafe wants to merge 1 commit intoRefactorio:developfrom
RedRafe:event-refactor

Conversation

@RedRafe
Copy link
Contributor

@RedRafe RedRafe commented Feb 2, 2025

I'm just gonna post this as a mean to share a code ideas, but no real plans to replace our current implementation.

Many checks for the correct _STAGE are missing as well as old documentation in event.lua not being updated, but I've loaded with some maps and it works just like previous, since event.lua acts as a backwards compatibility layer exposing all the old methods.

Miscellaneous of ideas:

1a. It could be possible to remove event.lua and only use event_core.lua (maybe renaming it to event.lua) by having the event module register its tables to the storage table & tokenizing the handlers passed to it itself, removing the dependency of global.luaandtoken.lua`.

1b. Moving small bits of logic to the event module may make it completely independent but it kinda breaks the single-responsibility principle, which I'm not too happy to do either.

2a. It could be simplified to always call Event.add(...)' around the code base and it'll automatically take care of registering whatever handler (function, token, string) it has been passed to it, with/without the on_tick_option`.

2b. On the other hand, keeping event.lua layer to add specific methods to call for on_tick/tokens/whatever could be easier to read/use? May be subjective. event.lua could still take care of input sanitization and stage checks while event_core.lua only handles the technical part of adding/removing

@RedRafe RedRafe added the WIP label Feb 2, 2025
@RedRafe RedRafe mentioned this pull request Feb 2, 2025
2 tasks
@RedRafe RedRafe closed this Feb 3, 2025
@RedRafe RedRafe deleted the event-refactor branch July 24, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant