Skip to content

Instantly share code, notes, and snippets.

View grapho's full-sized avatar

Seth Wright grapho

  • Subtle Medical Inc.
  • San Diego, CA
View GitHub Profile
@grapho
grapho / cp-macro.js
Created April 11, 2016 14:47 — forked from poteto/cp-macro.js
When you don't know what keys to observe for a CP, you can use a macro that determines the keys at runtime.
export default function makeComputed(objKey) {
let keys = Object.keys(get(this, objKey))
.filter((key) => {
// choose the keys using some logic
})
.map((key) => `${objKey}.${key}`);
return computed(...keys, {
get() {
// do stuff