Skip to content

Constructor call to prepare() prevents injection in concrete macroes. #49

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

Closed
D4rkL1ch opened this issue May 4, 2018 · 2 comments
Closed
Assignees
Labels

Comments

@D4rkL1ch
Copy link

D4rkL1ch commented May 4, 2018

Expected Behavior

When extending SequenceMacro to create own initialization behaviour, I want to use injection mechanism to create payloads and guards for the commands inside macro.

Current Behavior

prepare() method is called from the AbstractMacro constructor, which prevents injection to the super class.

Possible Solution

prepare() method should be called after all constructors have been called.

Steps to Reproduce (for bugs)

@inject(AppEvent) private _appEvent: AppEvent;

public prepare(): void {
	this.atomic = false;
	const payload = new SubCommandPayload(this._appEvent.payload, GameConfig);
	this.add(InitializeSpineSymbolCacheCommand)
		.withPayloads(payload)
		.withGuards(this._appEvent.payload.slotSymbolConfig !== undefined);
	this.registerCompleteCallback(() => this._eventDispatcher.dispatchEvent(new AppEvent(AppEvent.GAME_CONNECTED, this._appEvent.payload)));
}

Context

Not being able to inject event that has started the macro through mapping, creates the need for additional code, which would allow me to access data from the said event.

@tiagoschenkel
Copy link
Member

tiagoschenkel commented May 28, 2018

Hi @D4rkL1ch, sorry but I'm trying to understand what should be different to avoid this issue, but I was unable to find yet a solution.

Can you provide some additional solution, or how you think that your code should be when this issue is solved?

Feel free to call us directly in our Gitter channel or send me a PM.

@tiagoschenkel
Copy link
Member

@D4rkL1ch, the fix for this issue is released on version 0.2.1.

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

No branches or pull requests

2 participants