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

Use the special string only for context key #1

Closed
mjackson opened this issue Sep 29, 2016 · 4 comments
Closed

Use the special string only for context key #1

mjackson opened this issue Sep 29, 2016 · 4 comments

Comments

@mjackson
Copy link
Member

It seems like the only place we should use the special string is for the key on context, to avoid clashes with others. Everything else we can make generic.

const [ Emitter, Subscriber ] = createContextEmission('keyOnContext')

<Emitter value={someValue}/>

<Subscriber>
{value => (
  // ...
)}
</Subscriber>

Just seems like less docs to do it this way, no?

@ryanflorence
Copy link
Member

ryanflorence commented Sep 29, 2016

When you consider things like GeoSubscriber I'd want the APIs to be what I would have designed w/o this lib, like <GeoEmitter geo={geo}/> and <GeoSubscriber>{({ geo }) => ()}</GeoSubscriber>.

"Value" feels too generic for the result of this abstraction. Does that make sense? Like, I want the resultant API to be what I would have created w/o this library, had I done it manually.

<LocationSubscriber>{({ location }) => ()}</LocationSubscriber>
<GeoSubscriber>{({ geo }) => ()}</GeoSubscriber>
<MousePositionSubscriber>{({ mousePosition }) => ()}</MousePositionSubscriber>

@ryanflorence
Copy link
Member

If we used value then you'd end up with:

<LocationSubscriber>{({ value:location }) => ()}</LocationSubscriber>
<GeoSubscriber>{({ value:geo }) => ()}</GeoSubscriber>
<MousePositionSubscriber>{({ value:mousePosition }) => ()}</MousePositionSubscriber>

@mjackson
Copy link
Member Author

You should be able to name the arg whatever you want.

{(location) => ()}

{(pastaMaker) => ()}

Why does that arg need to be an object?
On Wed, Sep 28, 2016 at 10:47 PM Ryan Florence [email protected]
wrote:

If we used value then you'd end up with:

{({ value:location }) => ()}{({ value:geo }) => ()}{({ value:mousePosition }) => ()}


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAFqp7VekVLgHF2nRXsa3hd4dANAQUbqks5qu1DxgaJpZM4KJmXJ
.

Michael Jackson
@mjackson

@ryanflorence
Copy link
Member

Hmm ... I've been passing objects to render callbacks to keep a sort of symmetry with components and props, but I think you're right, the consumer can do that if they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants