Skip to content

🦺 Embrace singleton behavior & remove the footgun#32

Merged
zeenix merged 2 commits intolayerx-world:mainfrom
zeenix:embrace-singletons
Mar 25, 2026
Merged

🦺 Embrace singleton behavior & remove the footgun#32
zeenix merged 2 commits intolayerx-world:mainfrom
zeenix:embrace-singletons

Conversation

@zeenix
Copy link
Copy Markdown
Collaborator

@zeenix zeenix commented Mar 25, 2026

Currently if the user accidentally (people don't read docs) launch multiple instances of a controller, they'll end up having strange issue and have no idea what is going on.

Given that singletons are normal for actors and embassy_sync's channels are designed to be used as static variables, let's just embrace singletons, but ensure that no 2 instances of a controller can be created by returning an Option<Self> from the generated new method, which only returns Some the first time it's called.

zeenix added 2 commits March 25, 2026 22:18
Currently if the user accidentally (people don't read docs) launch
multiple instances of a controller, they'll end up having strange issue
and have no idea what is going on.

Given that singletons are normal for actors and embassy_sync's channels
are designed to be used as static variables, let's just embrace
singletons, but ensure that no 2 instances of a controller can be
created by returning an `Option<Self>` from the generated `new` method,
which only returns `Some` the first time it's called.
@zeenix zeenix merged commit 04f2c53 into layerx-world:main Mar 25, 2026
5 checks passed
@zeenix zeenix deleted the embrace-singletons branch March 25, 2026 21:45
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

Successfully merging this pull request may close these issues.

1 participant