ahdinosaur / inu

:dog2: composable unidirectional user interfaces using pull streams
207 stars 12 forks source link

[minor] add inu.action as sugar from send-action #14

Closed ahdinosaur closed 8 years ago

ahdinosaur commented 8 years ago

send-action has some nice sugar for dispatching actions. it's possible we wrap this within dispatch, but i'd rather it be separate and re-usable, allowing us to use it for any action creation while keeping start to a minimal core.

how it works:

// pass in an object and it returns it unchanged
var input = { type: 'things:create', thing: { name: 'computer' } }
var expected = input
assert.equal(inu.action(input), expected)

// pass in a type string and an object and it extends
// the object with 'type' as key and the string as value.
input = { thing: { name: 'computer' } }
expected = extend({ type: 'things:create' }, thing)
assert.deepEqual(inu.action('things:create', input), expected)

should work for many ways of handling actions (assuming actions are an object), not just 'namespace:key' action types (but i am liking this approach).

thoughts?

codecov-io commented 8 years ago

Current coverage is 98.25%

Merging #14 into master will decrease coverage by 1.75%

@@           master        #14   diff @@
========================================
  Files           4          5     +1   
  Lines          53         57     +4   
  Methods         0          0          
  Messages        0          0          
  Branches        0          0          
========================================
+ Hits           53         56     +3   
- Misses          0          1     +1   
  Partials        0          0          

Powered by Codecov. Last updated by 4b253d0...3ba1c1b

ahdinosaur commented 8 years ago

hmm, i'm not sure, i'm still figuring out what opinion i want to recommend for structuring nested apps.

ahdinosaur commented 8 years ago

yeah nah