Table of Contents:
import _ from 'lodash'; | |
import angular from 'angular'; | |
import 'angular-new-router'; | |
import 'oclazyload'; | |
function AppController ( ) { | |
} | |
AppController.$routeConfig = []; |
(*--------------------------------------------------------------------------- | |
Copyright (c) 2015 Daniel C. Bünzli. All rights reserved. | |
Distributed under the BSD3 license, see license at the end of the file. | |
%%NAME%% release %%VERSION%% | |
---------------------------------------------------------------------------*) | |
(* Simple generators according to: | |
Kiselyov, Peyton-Jones, Sabry | |
Lazy v. Yield: Incremental, Linear Pretty-printing |
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback | |
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; | |
// Open (or create) the database | |
var open = indexedDB.open("MyDatabase", 1); | |
// Create the schema | |
open.onupgradeneeded = function() { | |
var db = open.result; | |
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"}); |
import Color (Color, rgb) | |
import Graphics.Collage (..) | |
import Graphics.Element (Element) | |
import List ((::), map) | |
import Signal (Signal, foldp, (<~), sampleOn) | |
import Keyboard (arrows) | |
import Time (millisecond, every) | |
-------------------------- |
import List (map, (::)) | |
import Color (Color, rgb) | |
import Keyboard (arrows) | |
import Signal (Signal, (<~), foldp) | |
import Graphics.Collage (square, circle, move, filled, collage, Form) | |
import Graphics.Element (Element) | |
type alias Vector = { | |
x : Float, | |
y : Float |
#Exploring Entity Component Systems in Elm
Entity-Component-System (or ECS) is a pattern for designing programs that is prevalent in the games industry. This pattern consists of three simple parts:
- Entity : A uniquely identifiable object that may contain any number of components
- Component : A property usually representing the raw data of one aspect of the object. (Position is a component, Velocity is a component, Strength is a component, etc...)
- System : A continuous process performing actions on every entity that possesses a component of the same aspect as that system
To understand this, let us try to make a simple example: Boxes that move in space:
These rules are adopted from the AngularJS commit conventions.
var http = require('http'); | |
var express = require('express'); | |
var router = express.Router(); | |
/* GET users listing. */ | |
router.get('/', function(req, res) { | |
var request = require('request'); | |
var url = req.query.url; |
This document is a collection of concepts and strategies to make large Elm projects modular and extensible.
We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp
. You will probably merge
a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:
- There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo