Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Initialize singleton components on system registration #22

Closed
fernandojsg opened this issue Jun 24, 2019 · 2 comments
Closed

Initialize singleton components on system registration #22

fernandojsg opened this issue Jun 24, 2019 · 2 comments

Comments

@fernandojsg
Copy link
Member

Many times we need to store data related to systems internally, a good practice to avoid storing data on the systems could be to use singleton components and add some syntactic sugar for that:

If we create a system in this way:

world.registerSystem(SystemA, {valueA: 1, valueB: 2});

it will create a singleton component named systemA (As if we had previously created a SystemA component with valueA and valueB attributes).
And we could access the component from within the system by referencing this.component:

execute() {
    this.component.valueA += 2;
}
@joshmarinacci
Copy link
Contributor

Since you removed singletons should this be closed?

@fernandojsg
Copy link
Member Author

Yes, I'll just close it by now and reopen if we feel we want to add it as syntactic sugar

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

No branches or pull requests

2 participants