This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: code_lock.ex | |
# Translated from: http://erlang.org/doc/design_principles/statem.html#example-revisited | |
# callback mode: :state_functions | |
# | |
defmodule CodeLockCommon do | |
# Admittedly gratuitous use of a macro | |
# | |
def handle_event(:cast, {:down, button}, data) do | |
{:keep_state, Map.put(data, :button, button)} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: code_lock.ex | |
# Translated from: http://erlang.org/doc/design_principles/statem.html#example-revisited | |
# callback mode: :handle_event_function | |
# | |
defmodule CodeLock do | |
@behaviour :gen_statem | |
@name :code_lock_2 | |
def start_link(code), | |
do: :gen_statem.start_link({:local, @name}, __MODULE__, code, []) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<!-- file: index.html --> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Chapter 2: Your First Web Component</title> | |
<style> | |
my-custom-tag { | |
background-color: blue; | |
padding: 20px; | |
display: inline-block; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- | |
file: index.html | |
https://livebook.manning.com/#!/book/web-components-in-action/chapter-5/v-6/comment-487548 | |
https://github.com/bengfarrell/webcomponentsinaction | |
--> | |
<title>Web Harp</title> | |
<link href="./main.css" type="text/css" rel="stylesheet"> | |
<link href="./csshake.min.css" type="text/css" rel="stylesheet"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- | |
file: index.html | |
Web Components in Action MEAP v6 | |
https://livebook.manning.com/#!/book/web-components-in-action/chapter-7/v-6/comment-487676 | |
original: https://github.com/bengfarrell/webcomponentsinaction/blob/master/chapter7/7.5-slotsandtemplates/unnamedslots.html | |
#1: | |
prevent undefined custom element FOUC (flash of unstyled content) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// file: components/biz-card/biz-card.mjs | |
import { patchContentMap } from '../../helpers/templateLoader.mjs' | |
/* | |
#1: | |
See patchContentMap call below which creates | |
static get _contentMap | |
static set _templateUri | |
#2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<!-- | |
file: index.html | |
Web Components in Action MEAP v6 | |
original: https://github.com/bengfarrell/webcomponentsinaction/blob/master/chapter10/10.2-cssvariables/shadow.html | |
#1 | |
Defining a default value in case the custom property is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* file: components/wcia-color-picker/test/karma-test.mjs | |
original: https://github.com/bengfarrell/webcomponentsinaction/blob/master/chapter12and13/components/colorpicker/test/karma-test.js | |
*/ | |
import _dontCare from '../src/wcia-color-picker.mjs' | |
const makePicker = (function() { | |
const pickerSize = 500 | |
const thumbCenterOffset = 5/2 + 3 // width/2 + left border | |
const markup =` | |
<wcia-color-picker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file: lib/em_demo/some_handler.ex | |
# | |
defmodule EmDemo.AnotherHandler do | |
use GenServer | |
@impl true | |
def init([to_pid, token] = arg) do | |
IO.puts("#{__MODULE__}: init(#{inspect(arg)})") | |
{:ok, {to_pid, token}} | |
end |