Skip to content

Instantly share code, notes, and snippets.

Reactive Declarations

To avoid issues with re-calculating immediately on change while keeping reactive values in-sync, use reactive accessors to implement pull-based reactive values.

// Initialized with <Component a=15 />

export let a = 10;
let b = 20;
@timhall
timhall / reactive-declarations.md
Last active November 28, 2018 22:41
Pull-based reactive declarations

Reactive Declarations

To avoid issues with re-calculating immediately on change while keeping reactive values in-sync, use reactive accessors to implement pull-based computed values. Propose using computed for pull-based computed values that are kept synchronized and reactive to run functionality on initialize and before beforeUpdate.

Option 2 uses a single reactive: label and can re-run blocks as-needed based on when reactive values are accessed. I think there are a few downsides to this (side effects could happen at strange times), but it's a bit simpler since it presents a single reactive API.

// Initialized with <Component a=15 />
Private Const API_KEY As String = "YOUR_API_KEY"
Sub CreateTracking(Carrier As String, TrackingNumber As String)
Dim Client As New WebClient
Client.BaseUrl = "https://api.aftership.com/v4"
Dim Request As New WebRequest
Request.Resource = "trackings"
Request.Method = WebMethod.HttpPost
Request.AddHeader "aftership-api-key", API_KEY
@timhall
timhall / App.html
Last active November 27, 2017 20:10
svelte-router
<Route path="/" exact>
Home
</Route>
<Route path="/a">
A
<Route path="/a/nested">Nested</Route>
</Route>
<Route path="/b/:id">
B {{$router.params.id}}
</Route>

Keybase proof

I hereby claim:

  • I am timhall on github.
  • I am timhall (https://keybase.io/timhall) on keybase.
  • I have a public key ASAnerD4uXjGq9jjB0Pnk2wzWhqjDBmuu3s0ohwxJ5ZUGgo

To claim this, I am signing this object:

@timhall
timhall / taskr-run.js
Created July 27, 2017 13:17
task.run, unified approach
const co = require('bluebird').coroutine;
let taskId = 0;
class Task {
constructor(values = {}) {
const { id = `task${taskId++}`, files = [], globs = [], value } = values;
this.id = id;
this.files = files;
this.globs = globs;
@timhall
timhall / task-plugin-unification.md
Created July 27, 2017 13:04
Task / Plugin Unification
Error in user YAML: (<unknown>): mapping values are not allowed in this context at line 1 column 11
---
title: RFC: Task / Plugin Unification
---

Summary

This RFC presents an alternative plugin API that matches the current task API.

Unifying tasks and plugins should encourage task reuse (as plugins), simplify the overall API, and allow a single core mental model for how taskr tasks and plugins function.

@timhall
timhall / .block
Last active October 18, 2016 14:14 — forked from john-clarke/.block
BAA Marathon and Half-Marathon results as a histogram
license: mit
height: 550
border: yes
Private pClient As WebClient
Public Property Get Client() As WebClient
If pClient Is Nothing Then
Set pClient = New WebClient
pClient.BaseUrl = "https://ops.epo.org/3.1/"
' Setup authenticator (note: provide consumer key and secret here
Dim Auth As New OPSAuthenticator
Auth.Setup "CONSUMER_KEY", "CONSUMER_SECRET"
Sub PostFiles()
' Note: Add reference to Microsoft Scripting Runtime
' (Tools > References)
' References:
' http://www.xl-central.com/list-files-fso.html
' http://stackoverflow.com/a/20391100/1240745
Dim FSO As New FileSystemObject
Dim XmlFolder As Folder