raiondesu / eventhoven Goto Github PK
View Code? Open in Web Editor NEWEvent manager that composes events effortlessly ๐ต
Home Page: https://www.npmjs.com/package/eventhoven
License: MIT License
Event manager that composes events effortlessly ๐ต
Home Page: https://www.npmjs.com/package/eventhoven
License: MIT License
Current debugging system allows to set a custom debugging function, but there's no way to disable debugging with that custom function if a reference to it is lost (this could happen when dealing with switching isolated contexts like iframe
s or remote debugging ports).
It also requires passing an object 100% of the time, which is exhausting in itself.
Is there a way to make this work easier?
This is a shame for node<v12 users...
This event context should be introduced in some other way.
Need to remove this for now
Is your feature request related to a problem? Please describe.
Current README is getting very long and tedious to read. This might scare off some users that just want a simple event manager.
Describe the solution you'd like
A powerful solution to this would be a custom website for documentation with a possibility to code interactive tutorials (vuepress-based, maybe)?
Describe alternatives you've considered
Another solution would be to transfer docs to github wiki, but this provides no interactivity. And the structurization abilities are quire poor.
Is your feature request related to a problem? Please describe.
While #42 introduced a solid way to handle events in an OOP-style, it's still not a 1-to-1 mapping of all Eventhoven
functionality.
Currently, these things are missing from the implementation:
eventMap
function;Would allow to wait for event being emitted by returning a promise. Useful feature.
Jest is set up.
Only need to write them.
eventMap
emit
subscribe
(on
)subscribeToAll
(onAll
)unsubscribe
(off
)unsubscribeFromAll
(offAll
)wait
debug
eventCollection
emitCollection
subscribeCollection
unsubscribeCollection
metaEvents
emitMeta
It's a well-known use-case to await the execution of all events, while also allowing handlers to not block the execution flow.
This is needed. Soon.
There's a definite need to test typescript typings. It would be possible using something like dtslint.
Is your feature request related to a problem? Please describe.
It's understandable if a library is tuned to a specific programming style or paradigm, but it's never a good sign if a library restricts the end user in ways of achieving their goals.
A class API would solve the problem of a low compatibility of this library with the OOP-style.
Describe the solution you'd like
A class that utilizes event collections in order to encapsulate and combine the API.
Currently this yields cannot read property "set" of undefined
.
This is a direct consequence of using array.splice()
with array.findIndex
:
Currently, all eventhoven
functions are contextless (have no this
bound to them).
And this simplifies a lot of things.
However, handlers contain user's code. And a user may need to provide a separate context for them. So why not add it as a feature?
It is desirable to have bundles for every situation.
Right now, this lib lacks:
Currently, the debug
function is the only one that doesn't embrace the curried single-argument policy of the rest of this lib.
Currently, the debug output is very basic, showing only the essential info.
Here's how it could be improved:
Since the subscribe
function returns the unsubscribe
for the specific handler - why even pass the once
arg?
One could just immediately call the unsubscribe
inside of the handler!
Instead of just the current one.
Is your feature request related to a problem? Please describe.
Current way of result handling in emitters and handlers is half-baked - handlers can return data to emitters, but they do not have any knowledge or control on how this data is processed or handled.
Describe the solution you'd like
Provide a new property to the event context - a typed results
array that contains all the results of all previous handler's execution.
Example
on(someMap)('someEvent')(ctx => {
const isMyHandlerFirst = ctx.results.length === 0;
})
Currently, if you apply once
to a very expensive (computationally) handler, and then trigger the event it was subbed to from an async environment twice or more - the handler will still be executed more than once.
This happens because the once
function calls unsubscribe
after the handler finishes executing. Ideally, once
should unsub the handler right at the start of the execution to ensure the actuality of the event-map's state.
Describe the bug
It might be considered unexpected behavior when an event awaits all async meta-event-handlers before executing actual event handlers for the event.
To Reproduce
Steps to reproduce the behavior:
EMIT
meta-eventExpected behavior
Expected execution flow to not be blocked by the meta-event.
Environment (please complete the following information):
eventhoven
version: v0.11.0-rc.1Browser modules require special treatment in a form of a .js
extension appended to all module references.
This is, of course, solvable via a server settings (automated redirect from no extension to .js
extension), but this is a too complicated workaround for some situations.
Node works fine with .js
extensions too, btw.
Maybe do this only for emit
s?
Describe the bug
The type of the event context (TEventContext
) is not inferred correctly in event handlers passed to subscribe function.
To Reproduce
import { eventMap, on } from 'eventhoven';
const map = eventMap({
event(_): 42 { return 42; }
});
on(map)('event')(ctx => {
ctx.event; // string | number | symbol
ctx.unsubscribe // TUnsubscribe
});
Expected behavior
import { eventMap, on } from 'eventhoven';
const map = eventMap({
event(_): 42 { return 42; }
});
on(map)('event')(ctx => {
ctx.event; // 'event'
ctx.unsubscribe // TUnsubscribe<'event'>
});
Environment (please complete the following information):
eventhoven
version: v1.0.0Currently, handler's return values are void-ed, making no use of a possible feature.
Maybe allow event handlers to return a value, even if not a typed one?
This could be used for many things.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.