How to use the @observablehq/runtime.Library function in @observablehq/runtime

To help you get started, we’ve selected a few @observablehq/runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github severo / observable-to-standalone / bundle / joyplot / src / render.js View on Github external
// Import Observable library
import {Runtime, Inspector, Library} from '@observablehq/runtime';
import {customResolve} from './customResolve';
import {customFetch} from './customFetch';

// Fetch data locally
fetch = customFetch;

// Load modules locally
const runtime = new Runtime(new Library(customResolve));

// Render selected notebook cells into DOM elements of this page
export function render(notebook) {
  runtime.module(notebook, name => {
    switch (name) {
      case 'chart':
        // render 'chart' notebook cell into <div id="joyplot"></div>
        return new Inspector(document.querySelector('#joyplot'));
        break;
    }
  });
}
github codeforboston / windfall-elimination / src / library / generate-runtime.tsx View on Github external
export function generateRuntime(notebook) {
	 	const {modules, id} = notebook;
	 	var library = new Library();
	    var map = new Map;
	    var runtime = new Runtime(library);
	    const main = runtime_module(id);
	    

	    function runtime_module(id) {
		    let module = map.get(id);
		    if (!module) map.set(id, module = runtime.module());
		    return module;
	  	}

	 	for (const m of modules) {
	 		const module = runtime_module(m.id);
	 		let i = 0;
	 		for (const v of m.variables) {
	 				if (v.from) {

@observablehq/runtime

The **Observable Runtime** implements reactivity in both [Observable Framework](https://observablehq.com/framework/) and [Observable notebooks](https://observablehq.com/documentation/notebooks/).

ISC
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis

Similar packages