You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Although most of the time the user will, most likely, use only 1 EntityManagerT, the library supports multiple to be defined. If the user defines more than one he may also want to use the same callback for different EntityManagerT instances.
There are some problems with the current implementation:
if the callback is a function pointer, the user has no way to access EntityManagerT
if the callback is used across multiple instances the user has no way to know which was used
The implementation should change to the following signature:
voiddelegate(scope EntityManagerT, Entity)
The EntityManagerT should be scope to prevent it from escaping. This currently has some issues with DIP1000 and @safe code. When passed as scope all accesses must be scope compliant, requiring all functions to be defined with scope. This is an issue because it does not make sense to define the methods as scope for general use. Templating the functions might works in cases, from what I've tested, but I don't know if it can work as a solution for the entire lib.
An alternative to this is to refactor EntityManagerT to be a struct and not a class. With the struct approach callbacks could be defined as:
voiddelegate(ref EntityManagerT, Entity)
This fixes almost all issues with not much refactoring needing to be made. The downside is that the user will have to work with raw pointers.
The text was updated successfully, but these errors were encountered:
iK4tsu
changed the title
[Signal] All signals should pass the EntityManagerT was used
[Signal] All signals should pass the EntityManagerT that was used
Sep 6, 2021
Although most of the time the user will, most likely, use only 1 EntityManagerT, the library supports multiple to be defined. If the user defines more than one he may also want to use the same callback for different EntityManagerT instances.
There are some problems with the current implementation:
The implementation should change to the following signature:
The EntityManagerT should be
scope
to prevent it from escaping. This currently has some issues withDIP1000
and@safe
code. When passed asscope
all accesses must bescope
compliant, requiring all functions to be defined withscope
. This is an issue because it does not make sense to define the methods asscope
for general use. Templating the functions might works in cases, from what I've tested, but I don't know if it can work as a solution for the entire lib.An alternative to this is to refactor
EntityManagerT
to be astruct
and not aclass
. With thestruct
approach callbacks could be defined as:This fixes almost all issues with not much refactoring needing to be made. The downside is that the user will have to work with raw pointers.
The text was updated successfully, but these errors were encountered: