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

Better support for @:signal #43

Open
gene-pavlovsky opened this issue Aug 1, 2024 · 0 comments
Open

Better support for @:signal #43

gene-pavlovsky opened this issue Aug 1, 2024 · 0 comments

Comments

@gene-pavlovsky
Copy link
Member

Using tink_lang 0.6.4, the below code compiles but doesn't work as expected.
The constructor generated by tink_lang takes event from the constructor param, and creates a new _event signal trigger, because of the partial implementation in the interface.

With tink_lang 0.7.0, the below code doesn't compile (which is better than compiling to code that doesn't behave as expected).

If not too tricky, it would be nice if the generated code would take the _event signal trigger from the constructor param, and init the event from it, as normally happens when using the @:signal syntax.

package;

using tink.CoreApi;

class Test {
	static function main() {
		final trigger:SignalTrigger<Noise> = Signal.trigger();
		trigger.asSignal().handle(_ -> trace("Mischief managed"));
		new Emitter(trigger).emit();
	}
}

@:tink class Emitter implements IEmitter {
	//*
	@:signal var event:Noise = _;
	/*/
	public var _event:SignalTrigger<Noise> = _;
	public var event(get, null):Signal<Noise>;
		inline function get_event() return _event.asSignal();
	//*/

	public function emit() _event.trigger(Noise);
}

@:tink interface IEmitter {
	@:signal var event:Noise;
}
// build.hxml
-D no-deprecation-warnings

-lib tink_core
-lib tink_lang

-cp src
-main Test

-js bin/test.js

--cmd node bin/test.js
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

1 participant