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

fix(Subscription): Limit Subscription::closed public accessibility to readonly #2234

Closed
wants to merge 3 commits into from

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Jan 1, 2017

Description:

This PR changes the signature of ISubscription::closed to readonly.
Currently, it is allowed to change state of closed as well as unsubscribe() but those two are causing different outcome by unsubscribe actually does necessary teardown for unsubscription, while closed flag only changes state flag. Instead, this PR explicitly makes given flag as getter only to read state, otherwise let use unsubscribe() if needed.

This is indeed breaking change if anyone has been using closed to control subscription state, it won't work anymore. For now, I have targeted this to master until gets reviewed and approved.

BREAKING CHANGE: Cannot change closed state without unsubscribe()

Related issue (if exists):

rxTestScheduler.flush();

expect((schedulerMock as any).schedule).calledOnce;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while looking codes I noticed this test case actually did not assert anything, modified to have assertion but not sure if this is intended one - will update accordingly as suggested.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 97.675% when pulling 0ef4d83 on kwonoj:fix-subscription-closed into 6922b16 on ReactiveX:master.

@coveralls
Copy link

coveralls commented Jan 1, 2017

Coverage Status

Coverage decreased (-0.01%) to 97.675% when pulling 0537a32 on kwonoj:fix-subscription-closed into 6922b16 on ReactiveX:master.

@kwonoj kwonoj changed the title fix(Subscription): Limit Subscription.isClosed public accessibility to readonly fix(Subscription): Limit Subscription::closed public accessibility to readonly Jan 1, 2017
@coveralls
Copy link

coveralls commented Jan 1, 2017

Coverage Status

Coverage decreased (-0.01%) to 97.675% when pulling b64e50c on kwonoj:fix-subscription-closed into 6922b16 on ReactiveX:master.

@benlesh
Copy link
Member

benlesh commented Jan 4, 2017

I'm not sure why this change is necessary. How does it effect perf?

@benlesh
Copy link
Member

benlesh commented Jan 4, 2017

To clarify, we live in a world where window.undefined = "LOL" is possible. This change adds (albeit minor) complexity for no real gain, IMO.

@kwonoj
Copy link
Member Author

kwonoj commented Jan 4, 2017

Way I'm seeing this change is enhancing ergonomics with small complexity addition in codebases.

It is indeed this codebase is javascript and anyone can actually do anything if they try to avoid given interfaces, on the other hand if library's interface prevents any accidental incorrect usage, it would be better to prevent user's confusion.

Perfwise, previously it is just property access and with this change it'll be getter function, () => boolean. I do agree this adds complexity course, but it's small, though gain is also not quite hugh - small complexity, small gain.

If this change doesn't seems give sufficient benefit to library users, I'd like at least propose to update signature of ISubscription only which is free gain for typescript user without any codebase complexity- created #2249 for it.

@benlesh
Copy link
Member

benlesh commented Jan 13, 2017

Honestly, @kwonoj, I think I'm 👎 on this change and other changes like it. I'm happy with TypeScript enforcement (and possible _name "enforcement" in "private" or "protected" variables cases) for now.

I'm willing to be convinced otherwise, of course. But right now I'm not feeling it.

@kwonoj
Copy link
Member Author

kwonoj commented Jan 13, 2017

@Blesh fine for me. Just one thing, can we add this as agenda for next meeting about how much of runtime guarantee / validation we'd like to provide? Currently codebase barely does not provide anything on it, and this PR is kind of those to adding some more soundness on runtime (by introducing runtime complexity). As you can see, there are some of opened issues to demand certain level of runtime validation which non-TS user could benefit. User of TS this doesn't be too much issues for myself, but worth to think of where to draw those lines (such as it's already good as-is vs. we need something more)

Closing PR without checking it.

@kwonoj kwonoj closed this Jan 13, 2017
@kwonoj kwonoj deleted the fix-subscription-closed branch January 13, 2017 05:59
@benlesh
Copy link
Member

benlesh commented Jan 13, 2017

@kwonoj that's fine. I'm happy to discuss it.

I'm on the side of: "If you want soundness, use a type system, otherwise this is JavaScript and I'll duck-punch all the things I want"

Although, I really would like to go through and rename all private and protected variables to have underscores before them. That's been bothering me.

@kwonoj
Copy link
Member Author

kwonoj commented Jan 13, 2017

I really would like to go through and rename all private and protected variables to have underscores before them. That's been bothering me.

: That maybe sufficient soundness of runtime level we'd like to achieve. I think having settled down line would be great whatever level we'd like to have.

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants