-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Tidied up some code using optional map #2549
Tidied up some code using optional map #2549
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix! I added a clean-up suggestion.
} else { | ||
disposable = Disposables.create() | ||
} | ||
let disposable: Disposable = onDisposed.map({ Disposables.create(with: $0) }) ?? Disposables.create() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
} else { | ||
disposable = Disposables.create() | ||
} | ||
let disposable: Disposable = onDisposed.map({ Disposables.create(with: $0) }) ?? Disposables.create() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
…closure. Co-authored-by: Shai Mishali <[email protected]>
…er, instead of a closure.
Hey @freak4pc , I made the updates you suggested. Clever call with that! Let me know if there's anything else I can do. |
1198683
to
5949cbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Simply shortens/tidies up a few places of code, each of which were 3 lines, but could be written with just one using Optional's map function.
This feels like too small of change to mention in the changelog. If you disagree, let me know and I can make a mention.
I was also thinking of further condensing this code to the existing extension on
Disposables
inAnonymousDisposable.swift
:That way, the three places I cleaned up wouldn't each be repeating the same logic. Let me know if that's something you'd want.