Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

your-first-app work in progress #11

Merged
merged 8 commits into from
Jul 4, 2016
Merged

your-first-app work in progress #11

merged 8 commits into from
Jul 4, 2016

Conversation

timwis
Copy link
Member

@timwis timwis commented Jul 1, 2016

Just a start, let me know if you think it's on the right track

@yoshuawuyts
Copy link
Member

This is amazing! 🎉

@timwis
Copy link
Member Author

timwis commented Jul 3, 2016

Okay folks, I've finished this tutorial - I'd love some feedback! You can view it in the Files tab above and add inline comments, and click the View button at the top of the file to see it rendered in markdown.

I imagine this could be the first choo app newcomers build, so starting with the right best practises, naming conventions, ideas, etc. are important here. I'm open to all kinds of feedback. Thanks!

@@ -0,0 +1,650 @@
# Your first app

Let's build a simple todo application using choo. This tutorial assumes you're
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't use simple in here since it can potentially color someone's expectations of this works (they might not think what is happening is simple!). Can we change this to small?

@toddself
Copy link

toddself commented Jul 3, 2016

The only thing is that does send call the callback you're passing in in the effect? From what I understood, you needed to invoke the function when your effect was complete?

I'm just about to dive into the 3.0 upgrade process for my code though so I haven't played with this yet

},
reducers: {
addTodo: (data, state) => {
. . .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. . . used to confuse me a lot before I knew how to JS; like: is it real syntax? A comment would perhaps be more clear

@yoshuawuyts
Copy link
Member

Really liking this; great work hey ✨

One minor concern I have is overwhelming people with ES6 syntax; I think that even with the modest subset you've chosen for the examples here, it might be too much for people to feel comfortable with either if they're new to the language or are slowly inching back into it.

What I'd recommend doing is sticking to es2020 syntax and require('xtend') which both synergizes with choo's internals, is well documented and should allow people to create applications that work everywhere from the get-go (e.g. budo -- -t es2020). If anyone has knowledge or preferences beyond that; people are free to use whatever they want.

I recognize this is definitely a matter of taste though; but I feel it would be for the better.

@timwis
Copy link
Member Author

timwis commented Jul 4, 2016

Hey guys, great feedback all around, thank you. I've reduced the ES6 as you suggested, replaced "simple" with "small" and improved the explanation around unidirectional dataflow etc. Should be good to go then!

@timwis
Copy link
Member Author

timwis commented Jul 4, 2016

Going to merge, hope that's okay. Feel free to revert if not. Also, I removed the 2 dead links in the readme since we have #10 in place.

The only thing is that does send call the callback you're passing in in the effect? From what I understood, you needed to invoke the function when your effect was complete?

@yoshuawuyts, can you answer that when you get a sec? I was working off of choo's http example

@timwis timwis merged commit a599121 into master Jul 4, 2016
@timwis timwis deleted the your-first-app branch July 4, 2016 17:34
@yoshuawuyts
Copy link
Member

Remote now, but yes, send() must always be called when done - otherwise a caller up the stack (e.g. Another effect) will not know when it's done

@timwis
Copy link
Member Author

timwis commented Jul 4, 2016

What if your effect executes more than one reducer?

@yoshuawuyts
Copy link
Member

yoshuawuyts commented Jul 4, 2016

Like this ✨

function myEffect (data, state, send, done) {
  send('some:reducer', () => {
    send('some:otherReducer', done)
  })
}

Or using run-series:

const series = require('run-series')

function myEffect (data, state, send, done) {
  const reducers = [
    (done) => send('some:reducer', done),
    (done) => send('some:otherReducer', done)
  ]
  series(reducers, done)
}

And there's definitely ways of doing it with pull-stream, but I'm a noob so can't write it off the top off my head hah. Anyway; hope this answers your question 😁

edit:
Using pull-stream, I think:

const pull = require('pull')

function myEffect (data, state, send, done) {
  const source = [
    (done) => send('some:reducer', done),
    (done) => send('some:otherReducer', done)
  ]
  pull(source, pull.asyncMap(send), pull.drain(null, done))
}

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants