question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Where is this send comes from ?

See original GitHub issue
const document = require('global/document')
const choo = require('choo')
const http = require('choo/http')
const app = choo()

function view (params, state, send) {
  return choo.view`
    <form onsubmit=${onSubmit}>
      <fieldset>
        <label>username</label>
        <input type="text" name="username" autofocus>
      </fieldset>
      <fieldset>
        <label>password</label>
        <input type="password" name="password">
      </fieldset>
      <input type="submit" value="Submit">
    </form>
  `

  function onSubmit (event) {
    send('login', { data: new FormData(event.target) }) // where is the send comes from ?
    event.preventDefault()
  }
}

app.model({
  effects: {
    login: (action, state, send) => {
      http.post('/login', { body: action.data }, (err, res, body) => {
        send('authorize', { payload: body })
      })
    }
  }
})

app.router((route) => [
  route('/', view)
])

app.start()

edit by @yoshuawuyts: updated for syntax highlighting

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
timwiscommented, Jun 27, 2016

@crapthings note that onSubmit is a function within a function, thus it has access to the parent function’s scope.

1reaction
yoshuawuytscommented, Jun 30, 2016

@crapthings can I assume this has been resolved?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to determine where an email was sent from (tutorial)
This video explains how to trace an email back to where it originated (or was sent from). This does not mean that the...
Read more >
send it Meaning & Origin | Slang by Dictionary.com
Enticer's send it comes from the rock-climbing slang, send, a run in which a climber completes a route without falling or resting.
Read more >
send - Wiktionary
EtymologyEdit ... From Middle English senden, from Old English sendan (“to send, cause to go”), from Proto-West Germanic *sandijan, from Proto-Germanic *sandijaną ...
Read more >
Sent email in Outlook.com comes back "delivery failed"
Try these solutions if sent messages in Outlook.com come back with a "delivery failed" error.
Read more >
Send emails from a different address or alias - Gmail Help
Tip: You can send emails from up to 99 different email addresses. Step 1: Add an address you own. On your computer, open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found