Skip to content
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

Support passing function as param to flow, then executing it #264

Open
gene-pavlovsky opened this issue Feb 20, 2018 · 4 comments
Open

Support passing function as param to flow, then executing it #264

gene-pavlovsky opened this issue Feb 20, 2018 · 4 comments

Comments

@gene-pavlovsky
Copy link

I've added a function param to my flow file (it's intended as a callback).
I then try to call it in flow.
It throws an exception:

C:\foo\.haxelib\hexioc/0,34,0/src/hex/compiler/parser/flow/ObjectParser.hx:123: ERROR : Unknown expression
C:\foo\.haxelib\hexioc/0,34,0/src/hex/compiler/parser/flow/ObjectParser.hx:124: DEBUG : #pos(src/memberapplet/configuration/InitialContext.flow:5: characters 724-784)
C:\foo\.haxelib\hexioc/0,34,0/src/hex/compiler/parser/flow/ObjectParser.hx:125: func(memberAppletExternalInterfaceService.externalInterface)
C:\foo\.haxelib\hexioc/0,34,0/src/hex/compiler/parser/flow/ObjectParser.hx:126: DEBUG : ECall({ expr => EConst(CIdent(func)), pos => #pos(src/memberapplet/configuration/InitialContext.flow:5: characters 724-728) },[{ expr => EField({ expr => EConst(CIdent(memberAppletExternalInterfaceService)), pos => #pos(src/memberapplet/configuration/InitialContext.flow:5: characters 729-765) },externalInterface), pos => #pos(src/memberapplet/configuration/InitialContext.flow:5: characters 729-783) }])
src/memberapplet/configuration/InitialContext.flow:5: characters 724-784 : Invalid expression

As a workaround I pass that function to an initialization controller, which then calls it.

@gene-pavlovsky
Copy link
Author

Another workaround is to pass an object that contains the function, and call it as
object.function().
I suspect this might be already working in 0.35?

@FrancisBourre
Copy link
Collaborator

Thanks for the report. Can I see the original call (from the DSL) please?

@gene-pavlovsky
Copy link
Author

It was like this

@context(
	params = {
		externalInterfaceProviderWrapper: memberapplet.ExternalInterfaceProviderWrapper
		externalInterfaceProvider: memberapplet.service.externalinterface.IExternalInterfaceProvider,
		setExternalInterface: com.transport.externalinterface.IExternalInterface->Void
	}
)
{

	@map_type("memberapplet.service.externalinterface.IMemberAppletExternalInterfaceService")
	memberAppletExternalInterfaceService = new js.memberapplet.service.externalinterface.MemberAppletExternalInterfaceService();

	memberAppletExternalInterfaceService.init(externalInterfaceProvider);
	setExternalInterface(memberAppletExternalInterfaceService.externalInterface);

The last line is the problem :)
Current workaround:
I pass this param externalInterfaceProviderWrapper: memberapplet.ExternalInterfaceProviderWrapper
And then the last two lines are:

	memberAppletExternalInterfaceService.init(externalInterfaceProviderWrapper.externalInterfaceProvider);
	externalInterfaceProviderWrapper.setExternalInterface(memberAppletExternalInterfaceService.externalInterface);

This works.

@gene-pavlovsky
Copy link
Author

I will try to see if we can update to 0.35 and maybe it's already working there. In any case if you don't already have a test case like this, makes sense to add one.

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

No branches or pull requests

2 participants