An Rx question: I"ve just migrated to Rx 2 and on...
# random
c
An Rx question: I"ve just migrated to Rx 2 and only just realised I can no longer have
null
elements in streams. In cases where
null
is notionally valid; such as a stream to fetch some cached user data, where there may be none... is it advisable to model these as exceptions
NoUserDataException
?
w
chris-hatton: imo you should rather wrap your result in a class which will tell you whether you have data or not, as in
Copy code
class CachedData {
  List<Data> data; // might be null
}
👍 1
c
Thanks, I will mull it over.
Just wrapping it like you say does seem to be a fair solution
Bit of a questionable removal at first meeting; but I'm sure they had their reasons...
w
I usually use sealed classes for similar things
c
Yes, sealed classes ftw
So useful in many situations
w
Actually why do you want to emit
null
when there’s no data yet?
c
Heh, good question; it's a cop-out answer but also the truth to say I inherited this project
and they've implemented some... 'Rx lite'
w
Oh okay
c
where Rx has sometimes been used as a convenience to swap between sync and async datasources easily
and some sources emit Observable.just(null)
😨 2
when unset
w
Rx in wrong hands is reaaaaly difficult to work with
👍 1
c
its not really in the philosophy but I have to work with what I've got
done as much refactoring as I dare before the business are going to start demanding the next feature
its one of those
w
Yeah, makes sense