Skip to content

Instantly share code, notes, and snippets.

@NullVoxPopuli
NullVoxPopuli / machine.js
Last active April 29, 2020 02:24
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@NullVoxPopuli
NullVoxPopuli / machine.js
Last active April 25, 2020 02:49
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const parseScannedData = assign((context, event) => {
let { json } = event;
let isValid = Array.isArray(json);
if (!isValid) {
raise('SCAN_ERROR');
return context;
}
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@NullVoxPopuli
NullVoxPopuli / machine.js
Last active March 28, 2020 18:40
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@NullVoxPopuli
NullVoxPopuli / machine.js
Last active January 17, 2020 15:56
Generated by XState Viz: https://xstate.js.org/viz
// for emberclear.io
// "Transfer Account to a new Device"
const transferToDeviceMachine = Machine({
id: 'transfer-to-device',
initial: 'idle',
states: {
idle: {
on: {
// 1. (Source)
@NullVoxPopuli
NullVoxPopuli / page-objects-dont-have-to-suck.md
Last active January 11, 2020 23:47
Generic Adaptable Page Objects

Goals:

  • page objects should be cross-ecosystem, cross-technology
  • simple API
  • interop with Ember, and WebDriver (via adapters, which means testing-library would be supported, if anyone wanted to use that).
  • all async/awaitable
  • componentizable -- encourage separation of structure from the actual page object creation.
  • all properties lazily evaluated

Nomenclature:

  • Adapter: Converts meaning in to behavior -- "click" means different things to ember and webdriver
@NullVoxPopuli
NullVoxPopuli / proxy.js
Last active September 20, 2019 15:53
Native Proxy w/ Ember Object instances
import Ember from 'ember';
import ObjectProxy from '@ember/object/proxy';
import EmberObject from '@ember/object';
import { assert } from '@ember/debug';
let object = EmberObject.create({
name: 'Foo'
});
let object2 = EmberObject.create({
@NullVoxPopuli
NullVoxPopuli / controllers.application.js
Created June 11, 2019 19:32
Does a change in query params cause a transition?
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: ['a'],
actions: {
eh() {
this.set('a', Math.random());
@NullVoxPopuli
NullVoxPopuli / controllers.application.js
Last active June 10, 2019 02:49
Demonstrate Loading and Error Substates
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';
export default class ApplicationController extends Controller {
router = service('router');
current = reads('router.currentRouteName');
}