File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed
PlayBridgeJS/Sources/JavaScript
Sources/JavaScriptKit/Documentation.docc/Articles Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { init } from "./.build/plugins/PackageToJS/outputs/Package/index.js";
22const { exports } = await init ( { } ) ;
33
44const Greeter = exports . Greeter ;
5- const greeter = Greeter . init ( "World" ) ;
5+ const greeter = new Greeter ( "World" ) ;
66const circle = exports . renderCircleSVG ( 100 ) ;
77
88// Display the results
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export class BridgeJSPlayground {
5252 createTS2Skeleton : this . createTS2Skeleton
5353 }
5454 } ) ;
55- this . playBridgeJS = exports . PlayBridgeJS . init ( ) ;
55+ this . playBridgeJS = new exports . PlayBridgeJS ( ) ;
5656 console . log ( 'BridgeJS initialized successfully' ) ;
5757 } catch ( error ) {
5858 console . error ( 'Failed to initialize BridgeJS:' , error ) ;
@@ -162,4 +162,4 @@ export class BridgeJSPlayground {
162162 hideError ( ) {
163163 this . errorDisplay . classList . remove ( 'show' ) ;
164164 }
165- }
165+ }
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ In JavaScript:
133133import { init } from " ./.build/plugins/PackageToJS/outputs/Package/index.js" ;
134134const { exports } = await init ({});
135135
136- const cart = exports .ShoppingCart . init ();
136+ const cart = new exports .ShoppingCart ();
137137cart .addItem (" Laptop" , 999.99 , 1 );
138138cart .addItem (" Mouse" , 24.99 , 2 );
139139console .log (` Items in cart: ${cart .getItemCount ()} ` );
@@ -158,7 +158,7 @@ export interface ShoppingCart extends SwiftHeapObject {
158158
159159export type Exports = {
160160 ShoppingCart: {
161- init (): ShoppingCart ;
161+ new (): ShoppingCart ;
162162 }
163163}
164164` ` `
@@ -175,8 +175,8 @@ You can export functions to specific namespaces by providing a namespace paramet
175175import JavaScriptKit
176176
177177// Export a function to a custom namespace
178- @JS (namespace : " MyModule.Utils" ) func namespacedFunction () -> String {
179- return "namespaced"
178+ @JS (namespace : " MyModule.Utils" ) func namespacedFunction () -> String {
179+ return "namespaced"
180180}
181181` ` `
182182
You can’t perform that action at this time.
0 commit comments