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

order of sub and pub maters #4

Open
cekvenich2 opened this issue Sep 22, 2021 · 0 comments
Open

order of sub and pub maters #4

cekvenich2 opened this issue Sep 22, 2021 · 0 comments

Comments

@cekvenich2
Copy link

cekvenich2 commented Sep 22, 2021

If you pub before a sub it won't fire the event. When average developers build a complex event system with many nested components and fetching of data: it gets complex.
One way to simplify is to have pub work before a sub.
The example code I gave in the other code solves this issue. ( https://github.com/intuition-dev/mbToolBelt/blob/master/eventFlux/EventFlux.ts )
So a feature request: pub should work before a sub.

Example, only world2 works, world1 does not.

<script type="module">
import { createEventBus } from 'https://cdn.skypack.dev/ficusjs@3'

const eventBus = createEventBus()

eventBus.publish('myTopic', {hello: 'world1'})

eventBus.subscribe('myTopic', data => {
    console.log(data)
  })

eventBus.publish('myTopic', {hello: 'world2'})

</script>

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

No branches or pull requests

1 participant