Comments (11)
@ynnckcmprnl we have tried to be coherent with what the different APIs expose and respect it. In this particular case, having a new look at it, I kinda agree with you. @dmcrodrigues what do you think?
from rex.
Good point, we would need to make a new major release for this change tho. 😕
from rex.
We're still on 0.x releases so we can safely change this in 0.x+1 and be semver compliant.
from rex.
I'm not a fan of this change, even when ignoring the compilation errors I now get everywhere, this feels like a step backwards away from the "Swift way".
I found the type being a non optional String
a feature rather than a bug. When setting the text
property there's no difference between nil
or an empty String
, both have the same result, being an empty UILabel
. Hence MutableProperty<String>
simplified the use. Now, when testing whether a UILabel
is empty, we have to test whether the value is nil
and whether it's an empty String
.
Logically, an empty UILabel
contains an empty String
, the nil situation is/was an old Objective-C side-effect. Imho.
For instance a ViewModel exposes a username property of type MutableProperty<String>
, this used to match with rex_text
without having to add map's everywhere and manually handling the nil
situation.
Update 8/1/16: Changed UITextField
to UILabel
which I had mixed up. Issue was about UILabel
to start with.
from rex.
@ynnckcmprnl thanks for your feedback and I agree in reverting this. To ground this decision there's a discussion in the documentation that clearly states:
This string is
@""
by default.
I also have done a few tests and even when you clear a text field with a nil
value you always receive an empty string while accessing text
property.
@ynnckcmprnl are you interested in contributing this change?
from rex.
Note however that UILabel
, which was the issue stated here, should remain an optional string because it's nil
by default as we can see in the documentation.
from rex.
Darn, I seem to have mixed up UILabel
& UITextField
. My issue was indeed with UILabel
though, the post should have said UILabel
instead of UITextField
. I'll update the post to prevent further confusion.
I still stand by my original opinion, but the documentation stating nil
as default value does make it a hard sell.
Good catch regarding UITextField
, the change to MutableProperty<String>
should be inarguable.
from rex.
@ynnckcmprnl I don't think we should change this for UILabel
, the documentation clearly states that by default it's nil
so it's not case where the API exposed is not coherent but a case where we are making an assumption.
One thing we can do to help with this change is cherry-picking the support for binding with optionals.
struct ViewModel {
let name: MutableProperty<String>
}
// This will be possible without any mapping
nameLabel.rex_text <~ viewModel.name
This will help? @RuiAAPeres what do you think about this?
from rex.
@dmcrodrigues That would be exactly what I need.
from rex.
I wish that was included in RAC 4.x but unfortunately it will become available only in RAC5. Until then, I think we can provide it through Rex but I'll ask the opinion of @neilpa and @RuiAAPeres about this.
from rex.
@ynnckcmprnl kinda wasted effort to add this to Rex and just remove it again later on. It might be preferable to add this on your own codebase as a small extension and remove it, once you adopt RAC5.
from rex.
Related Issues (20)
- Publish 0.10 podspec to Cocoapods spec repo HOT 4
- Fill with Next(value) event with interval. HOT 10
- EXC_BAD_ACCESS when using rex_enabled with <~ operator HOT 10
- rex_text or UITextField is not called when it is cleared HOT 4
- Incompatible RAC 4.2.1 with Rex 0.10.0 HOT 1
- Transfer ownership to RACCommunity HOT 5
- Update bundle name HOT 2
- Release version 0.11 HOT 3
- rex_text for UITextField is property, but for UITextView SignalProducer HOT 1
- What properties are added to Rex? HOT 2
- rex_text in UITextView is not called for initial value HOT 1
- Allow to associate any type of object
- How can I handle error flow when I bind action to rex_pressed.value
- Release a version that supports Swift 2.3 HOT 4
- Support for ReactiveSwift HOT 4
- carthage bootstrap NSInvalidArgumentException HOT 1
- New release for RC1? HOT 2
- Use gyb from the Swift project for the AppKit/UIKit extensions HOT 4
- Rex 0.10 missing UIDatePicker.rex_date from framework binaries HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rex.