-
Notifications
You must be signed in to change notification settings - Fork 12
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
Finalize API and release 1.0.0 #1
Comments
Also considering |
+1 for |
Some version of the second API is the direction I am going to go. This makes detaching a listener O(1). I have merged the new API into master to help the discussion. Still not published to NPM and still room to discuss. Alternative APIs could be:
Similar to angular's
Which can still be O(1). |
@samuelmesq |
Other choice to make before 1.0.0 is to finalize the names of all the methods:
Other ideas? |
it's a matter of taste, i prefer short names like definitely but signals dont have a event name, is kind of weird read that way: about like i said matter of taste. Good Luck, have fun! |
I think |
I'm leaning towards:
Is it good to have both methods to detach Also, still debating if |
what the purpose of |
Currently the
Alternatively The advantage of returning a handler object vs. an unsubscribe function is that we can implement both |
@Hypercubed i get it, return the |
I like naming in the first post, |
Thank you @samuelmesq and @shergin. I think |
The distinction between returning an object containing a reference to the function or directly returning a reference to the function is so difficult! I really, really want to side with the object because of your point in your last paragraph in this post that we get two implementations for detaching signals. But then I kept asking myself why do we want to have two ways of doing it? What are the benefits or how they differ? In one we need the handle reference, so we have to hold on to that when we add our signal. In the other we need the signal and the handle's references. We likely already had access to the signal still, and so we are in the same position as the first with no real benefit other than explicitly re-stating the signal this handler is from. But if handlers are outputs from adding functions to signals, that distinction seems useless - there is no chance of a handler being used by multiple functions OR multiple signals as they are already one to one with the function attachments to the signal. The original js-signals implementation, while slower, does not have this distinction through the deprecated functionality: there is the chance that a function reference is added to the same signal multiple times -- in this case the ability to pass a function and a context can aid in distinguishing between these re-used adds. So that makes me think that it should just stay as simple as possible and just return the detach function directly. The other uses of such a returned object would totally change my thoughts - e.g. Hope this is helpful and not just me rambling, because now that I've typed it all I fele like I'm just rambling. |
@r4j4h Thank you very much for you input. I feel similar. I really want to return the handler object because it seems to have potential (e.g. jhusain/observable-spec spec suggests that "subscribe must return a subscription object.". But for some reason zenparsing/es-observable returns an unsubscribe function. One more thing I've been thinking of, that might have some impact on this decision, is the |
Another thought... returning the
or perhaps:
I've been considering if and how to implement priority. This would allow priority and still be O(1) on add. I'll probably add an |
It's interesting to see other libraries are already inconsistent in this regard. I like the ideas in I think you are right, But I really like that |
Purely semantic and minor, but maybe we should rename |
@divmgl Thank you for your input. I don't have a roadmap. This project started out as a minimal js-signals implementation to address v8 deoptimization (millermedeiros/js-signals#67). When I switched to linked lists I realized it was easy to implement some of @millermedeiros' v2.0 notes (millermedeiros/js-signals#60). Here are my thoughts:
|
I'd also like to keep the option of merging into js-signals open. |
For curried parameters I'd prefer That makes me wonder is there any difference between |
I also like the idea of removing the context argument on add.. Nowadays Need to remind that js-signals started back in 2010 and v1.0 was released I really like the idea of keeping the API/features as simple as possible. Also as a background story.. I had a branch that used linked lists (and was
|
Hi @millermedeiros, really great to have your input. Different times indeed.... in 2010 my primary language was FORTRAN. Fell free to interject as much as you would like. I'd also like to keep this API simple (after all I called it mini-). If later someone wants to make a more robust version they can add back someone of these features (e.g. auto rebind). In version 0.0.1 I was using some of the optimizations techniques from EventEmitter 3... then I realized that they basically implementing a very dumb (the algorithm, not the people) linked list. It was effectively a linked list for n < 2, then created an array. I tried just an LL and the difference was 2x in the benchmarks, real world applications will vary of course. |
I think at some point I'll create a wiki(s) page covering the API difference between mini-signals (pending v1.0) and js-signals. So far I have:
anything I'm missing? |
Hello all, thank you for your help. 1.0.0-beta is now on github in the 1.0.0 branch and on npm ( |
Hello all, thank you all again for your feedback. I have published v1.0.0 (actually v1.0.1 because my NPM foo is bad). This implements all the new API features we discussed and removes deprecated js-signals compatible API. Releasing v1.0.0 means that I have committed to the API and won't make breaking changes unless absolutely necessary. I'll try to follow semver ([breaking].[feature].[bugfix]) from here on out. The API details and a comparison of mini-signals to js-signals on the wiki. |
@Hypercubed I love your library. I'm currently using it in a project for an abstract router. As soon as I'm done with the implementation I'm going to make it public. In the meantime, I will add you as a contributor. Seriously, great work. |
@divmgl, thank you. Maybe the first usage in the wild! I see you are using mini-signals in ES6 through jspm. This is something I struggled with. I would have liked for JSPM users to be able to use the ES6 modules directly, but this would have meant, in some edge cases, ackward syntax like |
I'm thinking of following ericelliott's advice and dumping the Pro factory: No Thoughts? |
How would the syntax change? |
Instead of:
You would use:
(of course Here is some relevant links: https://medium.com/@_ericelliott/why-hate-on-class-inheritance-4c1067db3f03#6bc5 |
I'd say let's not over-complicate things. I like the regular signal syntax. It gives us the option of creating a factory implementation if we choose rather than having the factory pattern forced on us. |
I'll leave it as is for now since it is a breaking change for anyone relying on instanceof but something to think about. Signals are designed to be attached to objects, what is the use case for composing or inheriting from a signal? |
Hey @Hypercubed I'm going to open a separate issue for the factory implementation |
Congrats on 1.0, this is a really solid library |
Thanks, feel free to keep discussing... I just wanted to see 100% on the v1.0.0 milestone! |
I would like to finalize the API and release a 1.0.0 version. The current
mini-signals
API matches js-signals:My proposal for the first 1.x release is to return the binding object with a
detach
method:I'm looking for feedback.
The text was updated successfully, but these errors were encountered: