Skip to content

Instantly share code, notes, and snippets.

@timsgardner
Last active August 29, 2015 14:25
Show Gist options
  • Save timsgardner/10da9d05c4923ed06efb to your computer and use it in GitHub Desktop.
Save timsgardner/10da9d05c4923ed06efb to your computer and use it in GitHub Desktop.
mappy late-bound component logic idea
(defcomponent ProtagonistDriver [logic]
(Update [this]
(when-let [f (:update logic)]
(f this)))
(OnCollisionEnter [this that]
(when-let [f (:on-collision-enter logic)]
(f this that))))
@nasser
Copy link

nasser commented Jul 20, 2015

I like this a lot. What would the updating API be like? I guess you could

(set! (.. protagonist logic) new-map)

but a more map/record like interface would be awesome. Like

(assoc! protagonist :update new-fn)

The next question is where does state go? Is there a separate map? Do we just use fields?

I like where this is going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment