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

node: store callbacks in map #3772

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
node: store callbacks in map
  • Loading branch information
FloVanGH committed Oct 26, 2023
commit 53df2e75cd2027c4d4cffe4956af5f6e93ec03b1
9 changes: 8 additions & 1 deletion api/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ export interface LoadFileOptions {
libraryPaths?: Record<string, string>
}

let ComponentStore = {
callbacks: {}
};

/**
* Loads the given slint file and returns an objects that contains a functions to construct the exported
* component of the slint file.
Expand Down Expand Up @@ -425,7 +429,10 @@ export function loadFile(filePath: string, options?: LoadFileOptions) : Object {
return function () { return instance!.invoke(cb, Array.from(arguments)); };
},
set(callback) {
instance!.setCallback(cb, callback);
ComponentStore.callbacks[cb] = callback;
instance!.setCallback(cb, function (args) {
ComponentStore.callbacks[cb](args);
});
},
enumerable: true,
})
Expand Down