Skip to content

Commit

Permalink
on change callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikai B committed Mar 6, 2025
1 parent 1f7174a commit e48ac6a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ALCL.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/source" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Haxe toolkit" jdkType="Haxe toolkit" />
<orderEntry type="jdk" jdkName="Haxe 4.3.6" jdkType="Haxe toolkit" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file modified binary/Hashlink/out.hl
Binary file not shown.
14 changes: 14 additions & 0 deletions source/analysis/AnalyserType.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package analysis;
class AnalyserType {

private var _type: Null<String>;
private var _onChangeCallbacks: Array<Void->Void>;

public static function createUnknownType(): AnalyserType {
return new AnalyserType();
Expand All @@ -29,6 +30,15 @@ class AnalyserType {

private function new() {
_type = null;
_onChangeCallbacks = [];
}

public function onTypeChange(cb: Void->Void, runImmediately: Bool = true): Void {
_onChangeCallbacks.push(cb);

if (runImmediately) {
cb();
}
}

public function toFixed(): AnalyserFixedType {
Expand All @@ -45,6 +55,10 @@ class AnalyserType {

public function setType(typeName: String): Void {
_type = typeName;

for (cb in _onChangeCallbacks) {
cb();
}
}

public function hintIfUnknown(typeName: String): Void {
Expand Down

0 comments on commit e48ac6a

Please sign in to comment.