Code Monkey home page Code Monkey logo

Comments (11)

RuiAAPeres avatar RuiAAPeres commented on August 19, 2024 2

@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.

RuiAAPeres avatar RuiAAPeres commented on August 19, 2024

Good point, we would need to make a new major release for this change tho. 😕

from rex.

neilpa avatar neilpa commented on August 19, 2024

We're still on 0.x releases so we can safely change this in 0.x+1 and be semver compliant.

from rex.

ynnckcmprnl avatar ynnckcmprnl commented on August 19, 2024

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.

dmcrodrigues avatar dmcrodrigues commented on August 19, 2024

@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.

dmcrodrigues avatar dmcrodrigues commented on August 19, 2024

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.

ynnckcmprnl avatar ynnckcmprnl commented on August 19, 2024

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.

dmcrodrigues avatar dmcrodrigues commented on August 19, 2024

@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.

ynnckcmprnl avatar ynnckcmprnl commented on August 19, 2024

@dmcrodrigues That would be exactly what I need.

from rex.

dmcrodrigues avatar dmcrodrigues commented on August 19, 2024

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.

RuiAAPeres avatar RuiAAPeres commented on August 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.