Skip to content

Instantly share code, notes, and snippets.

// Basics
type Person = {
name: string
age?: number
}
const Bob: Person = {
name: "Bob",
}
// Somewhere your app
case class State(stuff: ...) // What your application uses to render itself
sealed trait AppTask extends WebWorkerTask // comes from the Granite framework
case class GetStuffFromAPITask(result: APIResponse = APIResponse.empty) extends AppTask
// Driver/Entry point for the Web App
object TutorialApp extends GraniteApp[State] with JSApp {
private val db = new LocalStorage[State]() // We want to serialize our App state to LocalStorage
private val dbKey = "state" // the "key" in the browser's LocalStorage object that houses our (JSON) serialized State
private val workers = new WebWorkerController(events, new WorkerPool(WorkerApp))
#include <stdio.h>
#include <pthread.h>
#define NUM_RECTS 1000000
#define NUM_THREADS 4
double gArea = 0.0;
pthread_mutex_t gLock;
void *threadFunction(void *pArg)