• Stars
    star
    424
  • Rank 102,315 (Top 3 %)
  • Language
    TypeScript
  • License
    BSD 3-Clause "New...
  • Created almost 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A starting point for web apps based on the actor model.

Actor Boilerplate

A starting point for web apps based on the actor model.

Screenshot of a stopwatch web app that uses the Actor model

Chrome Dev Summit 2018 Talk

Architecting Web Apps - Lights, Camera, Action!

We also wrote a series of blog posts with more detail on web development with the actor model:

What is this repository that am I looking at?

This is a very basic web app that uses the actor model. The actor model helps you to break your app’s core logic into small pieces that have to communicate with messages instead of using function calls. Adopting this model has multiple benefits on the web:

  • Yields to browser (it naturally leads to chunked code)
  • Encourages lazy-loading and code splitting
  • Gives you a clear separation of concerns
  • Makes moving code off-main-thread easier
  • Resilience against unexpected long-running tasks
  • Enables multi-modality for web apps

What’s in here?

This boilerplate is a starting point to build web apps based on the actor model. It provides a build system that allows you to easily lazy-load actors and split your code. It relies on actor-helpers for the implementation of the actors and the messaging system. (Please read the docs of actor.ts for more details and examples.)

Both this build system and the actor-helpers library are provided by us for convenience. You are encouraged to explore your own approach to actorize your code.

How do I use this?

To get started, you can either download a snapshot of the master branch or fork this repository. Then run:

$ npm install
$ npm run build
$ npm run serve

and navigate to the address shown on the console to see the app.

Static content

All content in static will be copied to the root of the output folder. This is the place for stylesheets, images and other files that don’t need any processing at build time.

Bootstrapping

The entire web app bootstraps itself by loading the bootstrap.ts entrypoint. This is where we initialize the messaging system and create workers.

Actors

All actors are in the src/actors folder. For example, the state actor runs in a worker as we call hookup("state", new StateActor()) in worker.ts. However, if an actor explicitly requires access to the DOM, you can use this call in bootstrap.ts as well.

The message system takes care of delivering messages, regardless of where the actor is run. We strongly encourage to default all actors in a worker and only run an actor on the main thread if necessary.

Note that while we have a single worker.ts in this project, larger projects can create as many workers as they like. Since messages are delivered irrespective of where an actor lives, you can assign any actor to any worker.

For example, if you have one actor that performs very expensive tasks, such as encoding and decoding messages, that actor can live in its own worker. Other (less CPU-intensive) actors can be grouped together in a single worker.

More examples

  • Todo note-taking app: Mandatory Todo app using the actor model with preact and ImmerJS (branch)

License BSD-3-clause

Please note: this is not a Google product.

More Repositories

1

wizzywid

What you see is what you deserve: a visual getting-started-tool for HTML, Custom Elements, and Polymer.
HTML
232
star
2

polydev

Automatic web components profiling in chrome devtools
HTML
123
star
3

lit-ssr

Experimental SSR for lit-html and LitElement
TypeScript
120
star
4

actor-helpers

TypeScript
108
star
5

crisper

JavaScript
106
star
6

todo-list

Polymer Summit Todo List App
HTML
96
star
7

uni-virtualizer

Monorepo for a "universal" (renderer-agnostic) virtual scroller and renderer-specific variants
TypeScript
95
star
8

zuperkulblog-progressive

A Progressive Web App built in Polymer
HTML
75
star
9

start-lit-element

Hello World app for LitElement.
JavaScript
68
star
10

arcs

Arcs
Kotlin
57
star
11

books

JavaScript
54
star
12

start-polymer3

A Hello World app for Polymer 3.0
JavaScript
52
star
13

html-modules-toolkit

Transforming HTML standards of the future into JavaScript standards of the past
TypeScript
47
star
14

indie-catalog

A simple catalog for demoing web components
HTML
44
star
15

lit-element-build-rollup

Build config for lit-element with Rollup and Babel
JavaScript
35
star
16

brick-viewer

A web component for viewing models built with a certain type of plastic brick!
TypeScript
35
star
17

async-demos

TypeScript
30
star
18

ristretto

An extensible test runner β˜•οΈ
TypeScript
30
star
19

polyicon

Polymer custom icon generator
HTML
30
star
20

shady-css-parser

A fast, small and flexible CSS parser.
TypeScript
28
star
21

cheese

HTML
27
star
22

polyperf

Simple webpage performance testing harness
HTML
26
star
23

split-element

Lazy loaded LitElements
TypeScript
24
star
24

template-instantiation

TypeScript
23
star
25

tedium

A bot for doing mass changes to github repos for the Polymer team
TypeScript
20
star
26

part-theme

Experimental proof of concept shim for ::part/::theme css.
JavaScript
19
star
27

lit-mail

TypeScript
18
star
28

polymer-2-carousel

Codelab
HTML
18
star
29

polymer-3-first-element

Create your first element with Polymer 3
JavaScript
16
star
30

amp-viewer

JavaScript
16
star
31

blocking-elements

Expose a stack of blocking elements https://github.com/whatwg/html/issues/897
JavaScript
15
star
32

iron-overlay

Overlay element that overcomes the stacking context trap
HTML
13
star
33

tsc-then

Like `tsc -w` but it runs a command of your choosing when compilation finishes
TypeScript
12
star
34

polymon

Seek out Polymer team members and capture them as Polymon! https://polymon.polymer-project.org
HTML
10
star
35

hot-elements

An interface for custom element classes to implement hot module reloading
9
star
36

project-health

TypeScript
9
star
37

perf-tester

An element to help performance test other elements.
JavaScript
8
star
38

PolymerRenamer

The Polymer Renamer helps developers integrate the Google Closure compiler with their Polymer projects by forwarding renames performed by the compiler to HTML and JS files.
Java
8
star
39

x-slides

Experimental slide deck elements.
TypeScript
7
star
40

prpl-ce-firebase

PRPL with Firebase Codelab
JavaScript
6
star
41

lit-html-build

Example Rollup build for lit-html
JavaScript
6
star
42

generator-polymer-init-vanilla-web-component

A Yeoman generator that scaffolds a vanilla web component template
HTML
6
star
43

css-slam

Minimal CSS, fast
TypeScript
6
star
44

template-instantiation-experiments

TypeScript
5
star
45

release-image

Generate Tweetable images from changelogs
TypeScript
5
star
46

lazy-lit-element

Non-blocking rendering for LitELement & UpdatingElement
5
star
47

lit-ssr-workspace

A workspace for working on lit-ssr and related projects
5
star
48

vexflow-elements

Web components for the VexFlow music notation renderer
JavaScript
5
star
49

news-docs

Polymer News documentation
HTML
5
star
50

empathy

Installing NPM modules for your front-end project? Pathify them with Empathy.
5
star
51

webmat

Web + format = webmat
TypeScript
4
star
52

angular-element

Experiment: Web Components with Angular Ivy templates
TypeScript
4
star
53

lit-plugin-docs

CSS
4
star
54

cancel-token

Implementation of https://github.com/littledan/proposal-cancelable-promises
TypeScript
4
star
55

arcs-cdn

Repository to serve as cloud provider (via gh-pages) for primary Arcs artifacts
JavaScript
3
star
56

grimlock

TypeScript
3
star
57

web-component-project-layouts

HTML
3
star
58

show-more

Element handling collapsible content with animation keyframes
HTML
3
star
59

simple-input

JavaScript
3
star
60

gen-closure-declarations

TypeScript
3
star
61

polymer-closure-sample

JavaScript
3
star
62

story-viewer

TypeScript
2
star
63

.allstar

2
star
64

koa-importmap

A Koa middleware module that can rewrite import specifiers for JavaScript modules based on the reference/presence of an importmap in the HTML document originating the request.
1
star
65

lit-samples

HTML
1
star
66

loose-it

Pre build Polymer bindings and property effects
TypeScript
1
star
67

kaon-experimental

Experiments in ES6 and Web Components
TypeScript
1
star
68

multitenant-prpl

prpl-server as a library test
HTML
1
star
69

story-viewer-starter

HTML
1
star
70

.github

1
star
71

async-dom

Async DOM APIs
HTML
1
star
72

template-benchmarks

A set of templating-related microbenchmarks
1
star
73

form-participation

Polyfill for the Form Participation API
TypeScript
1
star
74

polycasts

Source code for all your favorite polycasts!
HTML
1
star
75

awesome-sauce

A demo of an element with a documentation page.
JavaScript
1
star