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.

explicit signals connect in view package

See original GitHub issue

I don’t like that we expose all signals to each cerebral connected component. Also we can’t use constants to define signal path. Here is proposal:

connect({
  foo: 'some.state.path',                // exist
  bar: props => `some.entity.${byKey}`,  // exist
  baz: Computed(),                       // exist
  signals: {                             // proposal
    smthHappened: 'path.to.smthHappened'
  }
}, function Component ({ foo, bar, baz, signals }) {
  return (
    <div>
      <li>{foo}</li>
      <li>{bar}</li>
      <li>{baz}</li>
      <button onClick={e => signals.smthHappened()}>
    </div>
  )
})

or

connect({
  foo: 'some.state.path',                // exist
  bar: props => `some.entity.${byKey}`,  // exist
  baz: Computed(),                       // exist
}, {                                     // proposal
  smthHappened: 'path.to.smthHappened'
}, function Component ({ foo, bar, baz, smthHappened }) {
  return (
    <div>
      <li>{foo}</li>
      <li>{bar}</li>
      <li>{baz}</li>
      <button onClick={e => smthHappened()}>
    </div>
  )
})

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

4reactions
christianalfonicommented, Jul 14, 2016

I think we are taking way too much freedom on that one 😃 Technically we need to extract signals specifically… so I still favor:

connect({
  foo: 'some.state.path',                // exist
  bar: props => `some.entity.${byKey}`,  // exist
  baz: Computed(),                       // exist
}, {                                     // proposal
  smthHappened: 'path.to.smthHappened'
}, function Component ({ foo, bar, baz, smthHappened }) {
  return (
    <div>
      <li>{foo}</li>
      <li>{bar}</li>
      <li>{baz}</li>
      <button onClick={e => smthHappened()}>
    </div>
  )
})

And it reads very well:

  1. What state deps has this component
  2. What signals does this component use
  3. The component

It is also similar to connect by Redux:

  1. State
  2. Actions
  3. Component
2reactions
christianalfonicommented, Jul 17, 2016

Hehe, I have a tendency to stretch my opinions as far as I can 😉

But I still think namespaced is the wrong way to go. When we compare the two approaches there are more negatives on the state/signals namespace approach than extending with a second argument:

namespace negatives

  • We change current api
  • If you write state/signals wrong it will not work
  • To support both old and new api we have to create special temporary code that is prone for bugs
  • With components that does not use signals we are increasing syntax
  • There will never be more than state/signals put into components so it is weird to have only two static properties on an object. Objects are suited for dynamic properties
  • We force nested destructuring, which is more syntax again and harder to read

extra argument negatives

  • I can not find any negatives? 😃
Read more comments on GitHub >

github_iconTop Results From Across the Web

Signals | Django documentation
Signals are implicit function calls which make debugging harder. If the sender and receiver of your custom signal are both within your project,...
Read more >
Transport Protocol Path Signals RFC 8558
Where the endpoints desire that network elements along the path receive these signals, this document recommends explicit signals be used.
Read more >
signal package - os/signal
Package signal implements access to incoming signals. ... However, some signals are explicitly unblocked: the synchronous signals, SIGILL, SIGTRAP, ...
Read more >
Signals and Slots — Flow Framework 8.1.x documentation
This is the place to wire signals to slots as needed for your package. This can be done using the connect() and wire()...
Read more >
How to Increase Ecommerce Conversion Rates with Signals
Common examples of explicit signals include purchases, ratings, social posts, searches, and returns (negative). Explicit signals generally ...
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