Skip to content

Instantly share code, notes, and snippets.

View darrenjennings's full-sized avatar
🗜️
guuu

Darren Jennings darrenjennings

🗜️
guuu
View GitHub Profile
@darrenjennings
darrenjennings / machine.js
Created February 25, 2021 17:33
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@darrenjennings
darrenjennings / machine.js
Created January 13, 2021 19:35
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@darrenjennings
darrenjennings / machine.js
Last active June 9, 2020 18:39
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@darrenjennings
darrenjennings / useSWR.vue.ts
Created January 24, 2020 22:31
useSWR for Vue hooks
import { Ref, reactive, onMounted, watch, toRefs } from '@vue/composition-api'
// const { data, error } = useSWR('/api/user', fetcher)
export type fetcherFn<Data> = (...args: any) => Data | Promise<Data>
function isDocumentVisible (): boolean {
if (
typeof document !== 'undefined' &&
typeof document.visibilityState !== 'undefined'
) {
@darrenjennings
darrenjennings / useMachine.ts
Created January 19, 2020 00:17
vue useMachine.ts
import { StateMachine, interpret, EventObject } from '@xstate/fsm'
import { ref, Ref, onBeforeMount } from '@vue/composition-api'
export default function useMachine<TContext, TEvent extends EventObject = EventObject> (
stateMachine: StateMachine.Machine<TContext, TEvent, any>): {
current: Ref<StateMachine.State<TContext, TEvent, any>>,
send: StateMachine.Service<TContext, TEvent>['send'],
service: StateMachine.Service<TContext, TEvent>,
} {
const current = ref(stateMachine.initialState) as Ref<StateMachine.State<TContext, TEvent, any>>
<template>
<div>
<div class="stutterer">
<svg
height="310"
width="310">
<circle
ref="face"
class="clockFace"
cx="155"
@darrenjennings
darrenjennings / index.html
Created January 4, 2018 08:17
skatejs-vue 1221 proto
<x-vue yell>Dude</x-vue>
@darrenjennings
darrenjennings / App.vue
Last active January 12, 2018 00:57
Vue Render Prop - Parent
<template>
<div id="app">
<Mouse :render="__render"/>
</div>
</template>
<script>
import Mouse from "./Mouse.js";
export default {
name: "app",
@darrenjennings
darrenjennings / Mouse.js
Last active January 12, 2018 00:56
Vue Render Prop - Child
const Mouse = {
name: "Mouse",
props: {
render: {
type: Function,
required: true
}
},
data() {
return {
import { shallow } from "vue-test-utils";
import { createRenderer } from "vue-server-renderer";
import VueToAKill from "../src/VueToAKill.vue";
const defaultProps = {
agents: ['James Bond', 'Alec Trevelyan', 'M', 'Q'],
licenseToKill: true
};