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

Gtk.ListBox should be iterable #193

Open
vixalien opened this issue Aug 20, 2024 · 3 comments
Open

Gtk.ListBox should be iterable #193

vixalien opened this issue Aug 20, 2024 · 3 comments

Comments

@vixalien
Copy link

In GJS, it seems to be iterable. Might also be useful to know which other types are iterable.

See https://github.com/workbenchdev/demos/blob/3d05940216e007b4b3681d8a8d620d5aedcf73fb/src/Drag%20and%20Drop/main.js#L12

@vixalien
Copy link
Author

I asked which types are known to be iterable in the GNOME JavaScript channel on Matrix, and I got a response from ptomato:

the iterable types are ones that explicitly have a [Symbol.iterator] method added in modules/core/overrides/*.js. we try to use that sparingly because depending on the type, it can be deceptively more expensive than it looks.

From a quick look, I found the following iterable types:

  • Gio.ListStore
  • Gio.FileEnumerator (also has an [Symbol.asyncIterator])
  • Gtk.Widget

@hdonnay
Copy link

hdonnay commented Sep 11, 2024

Relatedly, Gio.InputStream has createSyncIterator and createAsyncIterator: documentation

@JumpLink
Copy link
Collaborator

Hello @vixalien thanks for the issues, I am currently developing my own GNOME application in TypeScript in my limited free time to do the complete process to the finished application myself. As soon as I have a little more time or have finished the first release, I will concentrate more on ts-for-gir again

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

3 participants