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

Added UITextView text's producer #95

Merged
merged 2 commits into from
Apr 11, 2016

Conversation

RuiAAPeres
Copy link
Member

No description provided.

public var rex_textSignal: SignalProducer<String, NoError> {
return NSNotificationCenter.defaultCenter()
.rac_notifications(UITextViewTextDidChangeNotification, object: self)
.filterMap { notification in

Choose a reason for hiding this comment

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

Just a suggestion (not necessarily any better, depending on how you value code clarity etc), but might something like .filterMap { ($0 as? UITextView)?.text } be simpler?

Copy link
Member Author

Choose a reason for hiding this comment

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

That is not equivalent. the $0 is a NSNotification. $0.object is a UITextView. I am ok with the change:

    public var rex_textSignal: SignalProducer<String, NoError> {
        return NSNotificationCenter.defaultCenter()
            .rac_notifications(UITextViewTextDidChangeNotification, object: self)
            .filterMap  { ($0.object as? UITextView)?.text }
    }

But then I would like to change the UITextField (for consistency sake). @neilpa what do you think?

Choose a reason for hiding this comment

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

Sorry, yes — that was just me not paying enough attention.
($0.notification.object as? UITextView)?.text

Copy link
Member

Choose a reason for hiding this comment

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

If you want to make that change and update UITextField I'm fine with that.

@neilpa neilpa merged commit 50a97ba into RACCommunity:master Apr 11, 2016
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

Successfully merging this pull request may close these issues.

3 participants