These are chat archives for jdubray/sam

22nd
Dec 2016
Vincent Jo
@chiwoojo
Dec 22 2016 03:13
what's your ideal redux set up Zach
just curious
Fred Daoud
@foxdonut
Dec 22 2016 03:41
@devinivy how do you mean? what if dispatch was model.present instead?
Jean-Jacques Dubray
@jdubray
Dec 22 2016 03:59
@foxdonut not sure if you saw Mike McNeil presentation on What even is Software: https://www.youtube.com/watch?v=nZKG7hLhbRs, I think he introduces similar concepts but in plain JavaScript
It's part of the "node-machine" project: http://node-machine.org/
This is what a node-machine looks like:
module.exports = {
  friendlyName: 'Do something',
  description: 'Do something with the provided inputs that results in one of the exit scenarios.',
  extendedDescription: 'This optional extended description can be used to communicate caveats, technical notes, or any other sort of additional information which might be helpful for users of this machine.',
  moreInfoUrl: 'https://stripe.com/docs/api#list_cards',
  cacheable: true,
  sync: true,

  inputs: {
    apiKey: {
      description: 'The api key to be used.',
      required: true,
      example: 'foo',
      whereToGet: {
        url: 'https://dashboard.stripe.com/account/apikeys',
        description: 'Copy either "Test Secret Key" or "Live Secret Key" from your Stripe dashboard.',
        extendedDescription: 'You will first need to log in to your Stripe account, or create one if you have not already done so.'
      }
    }
  },

  defaultExit: 'success',

  exits: {
    success: {
      example: 'myApiKey',
      description: 'Returns the API key for your totally fake account',
      variableName: 'rateLimitMetadata'
    },
    error: {
      description: 'Unexpected error occurred.'
    }
  },

  fn: function(inputs, exits) {
    // ...
    // your code here
    var result = 'foo';
    // ...
    // ...and when you're done:
    return exits.success(result);
  };
}
Edward Mulraney
@edmulraney
Dec 22 2016 07:53
node-machine looks really interesting. i've been thinking about what an app as config would look like for the front end and it was something similar to that. theres just something not nice about big config definitions
Jean-Jacques Dubray
@jdubray
Dec 22 2016 12:33
yes, I agree, but in the end he is redefining how a function is wired (which I really like, of course).
Vincent Jo
@inrix-vincent-jo
Dec 22 2016 20:34
I don't understand this node-machine thing..
is it a function that has error handling basically?
was looking at some samples and briefly read over the spec.. doesn't click right away for me
Jean-Jacques Dubray
@jdubray
Dec 22 2016 22:21
yes, this is just a different wiring for a function, the way I see it, it's a bit like Spring and an inversion of control / DI. That's why I recommend keeping / thinking about the wiring as distinct from the programming model. The programming model did not change, a function is still a function, however the wiring makes it easier to integrate with the code that uses that function, as opposed to returning a single result followed by some error handling code.
He also added some metadata, but that's just syntactic sugar, nothing earth shatering.