Skip to content

Commit

Permalink
fix: remove filter callback
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
  • Loading branch information
vados-cosmonic committed Feb 5, 2025
1 parent dd3b47c commit 3242131
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
5 changes: 1 addition & 4 deletions examples/components/webidl-book-library/book-library.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ dictionary Book {
unsigned short pages;
};

// WebIDL Callbakcs are turned into functions
callback FilterCallback = boolean (Book book);

// WebIDL interfaces become WIT resources
interface Library {
readonly attribute unsigned long totalBooks;
Expand All @@ -45,7 +42,7 @@ interface Library {
};

interface AdvancedLibrary : Library {
FrozenArray<Book> filterBooks(FilterCallback callback);
FrozenArray<Book> filterBooks(DOMString name);
};

partial interface Library {
Expand Down
2 changes: 1 addition & 1 deletion examples/components/webidl-book-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Example WebAssembly component showcasing WIT interfaces auto-generated from WebIDL",
"type": "module",
"scripts": {
"generate:wit": "webidl2wit book-library.webidl",
"generate:wit": "webidl2wit book-library.webidl -o wit/book-library.wit",
"build": "jco componentize book-library.js --wit wit/ --world-name revup --out book-library.wasm --disable all",
"all": "npm run generate:wit && npm run generate:types && npm run build"
},
Expand Down
38 changes: 38 additions & 0 deletions examples/components/webidl-book-library/wit/book-library.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package examples:book-library;

interface default {
enum book-genre {
fiction,
non-fiction,
mystery,
fantasy,
science-fiction,
biography,
}
type dom-string = book-title;
record book {
title: book-title,
author: string,
genre: option<book-genre>,
pages: option<u16>,
}
resource library {
total-books: func() -> u32;
add-book: func(book: book) -> bool;
remove-book: func(title: string) -> bool;
get-book-by-title: func(title: string) -> option<book>;
list-books: func() -> option<list<book>>;
as-advanced-library: func() -> option<advanced-library>;
library-name: func() -> library-name;
rename-library: func(new-name: library-name) -> void;
}
resource advanced-library {
as-library: func() -> library;
filter-books: func(name: string) -> list<book>;
}
type dom-string = library-name;
resource book-manager {
library: func() -> library;
init-library: func(name: library-name) -> void;
}
}

0 comments on commit 3242131

Please sign in to comment.