These are chat archives for freeman-lab/discussion

2nd
Mar 2016
Nicholas Sofroniew
@sofroniewn
Mar 02 2016 08:51
@freeman-lab @andrewosh here's a repo demoing the use of redux to implement the 2AFC task with a timeout and logging of the data https://github.com/sofroniewn/redux-2AFC
Jeremy Freeman
@freeman-lab
Mar 02 2016 17:41
@sofroniewn nice! that looks really cool
what is this syntax?? const timeoutScheduler = store => next => action =>
that's the only part i don't get
i finally figured out a front end pattern i really like @andrewosh, here's a gist
just need a clever way to expose dispatch to the components
Nicholas Sofroniew
@sofroniewn
Mar 02 2016 17:50
that's function composition in ES6 - I copied the example from http://redux.js.org/docs/advanced/Middleware.html
Andrew Osheroff
@andrewosh
Mar 02 2016 18:50
@freeman-lab interesting, throwing 3 new modules at me :P
Jeremy Freeman
@freeman-lab
Mar 02 2016 18:51
that's life in module.land
Andrew Osheroff
@andrewosh
Mar 02 2016 18:51
looks pretty similar to the other version yeah?
Jeremy Freeman
@freeman-lab
Mar 02 2016 18:51
yeah but it uses virtual-dom instead of morphdom, which for reasons i'll explain i think i like better
Andrew Osheroff
@andrewosh
Mar 02 2016 18:52
ah ok cool
Jeremy Freeman
@freeman-lab
Mar 02 2016 18:52
i'm stuck on one point i think you can help on, and then might have something really nice
Andrew Osheroff
@andrewosh
Mar 02 2016 18:52
exposing the dispatch to the subcomponents?
Jeremy Freeman
@freeman-lab
Mar 02 2016 18:52
yup exactly
will be in soon, need to do a quick skype
Andrew Osheroff
@andrewosh
Mar 02 2016 18:52
ah k cool
Jeremy Freeman
@freeman-lab
Mar 02 2016 18:52
but maybe think about how to do it
i kinda want to be able to do this
var hx = require('./index/hx')
var dx = require('./index/dx')

module.exports = function (state) {
  function onclick () {
    dx({ type: 'INCREMENT'})
  }
  return hx`<div><span>${state}</span><button onclick=${onclick}></button></div>`
}
where dx dispatches to the store
but somehow that needs to reference the store itself from down below
Matthew Conlen
@mathisonian
Mar 02 2016 20:51
@freeman-lab react-redux has a pretty elegant solution to that if you haven’t seen it http://redux.js.org/docs/basics/UsageWithReact.html, im sure the same idea can be applied without actually using react
Jeremy Freeman
@freeman-lab
Mar 02 2016 20:52
@mathisonian haha i started exploring this because i found that solution really confusing
but am still working through it all
Matthew Conlen
@mathisonian
Mar 02 2016 20:54
haha fair
it made sense to me after i watched that video tutorial he made, but id be interested to hear if you come up with something more intuitive
Jeremy Freeman
@freeman-lab
Mar 02 2016 20:56
you’re definitely right, i just want something that connects hyperx and virtual-domto redux, so it’s the same problem
Seth Vincent
@sethvincent
Mar 02 2016 23:48
@freeman-lab let me know if i can help with virtual-dom stuff
this example seems like it's doing roughly what you're describing with hyperx: https://github.com/yoshuawuyts/playground-virtual-app/blob/master/index.js
Jeremy Freeman
@freeman-lab
Mar 02 2016 23:55
@sethvincent cool! yeah haha literally in the last few days this stuff has taken over the lab =)
@sofroniewn had the really cool realization that this model might be really well suited to hardware control, which he’s been trying to do in node.js
Nicholas Sofroniew
@sofroniewn
Mar 02 2016 23:57
@sethvincent yeah would be really interested to get your take on this - just about to push an update
enormous parallels between front-end UI, game engines, and hardware control for experiments
Seth Vincent
@sethvincent
Mar 02 2016 23:59
@sofroniewn definitely