net.coruscation.js4clj.context

*after-init-hook*

dynamic

A fn takes no arguments, called after a context is created, with *context* bound to the newly created context.

*context*

dynamic

When `*context-per-thread*` is false, deref it returns the global context,
When `*context-per-thread*` is true, deref it returns the thread local context.

In any case, if it is not already initialized, initialize it with `context-new`

You can bind it with an IDeref instance to manage context.

*context-per-thread*

dynamic

Whether to use thread local context when doing js4clj operations.

*customize-builder*

dynamic

A fn takes a `Context$Builder` as an argument and returns a `Context$Builder`

*js-cwd*

dynamic

cwd of the javascript environment when doing `require` or `import`.
In most cases it is the directory contains `node_modules`

Default: cwd of the Clojure process

*js-resource-path*

dynamic

context-new

(context-new)
Create a context, respect `customize-builder` and `after-init-hook`

default-builder

(default-builder)
Return a `org.graalvm.polyglot.Context$Builder` object with necessary options set for js4clj to function properly.

 You can build more JS context with it, then dynamic binding *context* variable to use multiple JS contexts in
multiple threads. For example:

 ```clojure
 (binding [*context* (atom (.build (default-builder)))]
   (future ...))
 ```

 

reinitialize-context!

(reinitialize-context!)
If `*context-per-thread*` is false, reinitialize the global `*context*` with `context-new`.
If `*context-per-thread*` is true, reinitialize the thread-local context with `context-new`.

Note: Contexts are automatically initialize upon first usage  if not already initialized.