Getx: What purpose of using extension on Object?

Created on 28 Jun 2020  路  8Comments  路  Source: jonataslaw/getx

I checked code and found that you have an extension on object
extension ObjectExtension on Object { Rx<Object> get obs => Rx(this); }

I suggest to make it as generic, it makes more sense:
extension RxT<T> on T { Rx<T> get obs => Rx(this); }

Most helpful comment

don't know if it helps, but i am using Flutter 1.17.4 (stable channel) and it happens just like @SHRJamal showed.

image

All 8 comments

I checked code and found that you have an extension on object
extension ObjectExtension on Object { Rx<Object> get obs => Rx(this); }

I suggest to make it as generic, it makes more sense:
extension RxT<T> on T { Rx<T> get obs => Rx(this); }

I think there is no semantic difference between the two approaches.
Do you think it gets clearer with <T>?

I can't see any practical differences in this approach, but if it's more readable to other devs, I can change that.

when you do .obs on non-primitive types, you lose the type.
for example user.obs gives Rx<Object>, It should be Rx<User> instead.
With the solution, I gave it will solve this.

I also have some other suggestions on code cleaning and recommend to add effective-dart lint rules. so that we have common rules for future contributions.
I can make pull request if you want. I like this packages and would love to contribute.

Screen Capture_select-area_20200628153031
Screen Capture_select-area_20200628153057

I was unable to reproduce this, but either way, I will consider it for the next update.

Screen Shot 2020-06-28 at 19 44 49

Here it' s really doesn't, just think about it. that should not be allowed by dart anyway

Dart behaving differently on different machines, lol.
Thank you for mentioning this, as it never happened on my side, it was never my concern, I am changing this and I will update it.

don't know if it helps, but i am using Flutter 1.17.4 (stable channel) and it happens just like @SHRJamal showed.

image

Changed on last version, thanks.

Was this page helpful?
0 / 5 - 0 ratings