As of version 2.2, Simple Finance Planner calls sqlite operation directly from the main thread. Yes, I’m aware it’s not a good practice, but practically in real life, for Simple Finance Planner it doesn’t matter (as least at this point of time). I’ve tested Simple Finance Planner on low-end phones (Xperia Mini low-end kind) with hundreds of data and all the data loads fast without any problem or ANR issue. Coupled with the fact that using Loader with sqlite access is kind of terrible, hence I’ve been holding off from fixing this issue.
That’s until a few weeks ago when I was going through Simple Finance Planner code and stumbled upon some codes that utilize RxAndroid. This portion of code works as intended, without any problems or whatsoever, but I have problem explaining to myself how this code works. It reminds me that I did this portion of code about a year ago without fully understanding it – sure it works as intended without any problem, but then again, not be able to explain your own code is a pretty serious issue. (In my defense, this was a rushed code because of other deadlines heh)
This made me go through all the RxJava tutorials that I’ve read previously, and I think I can conclude that the reason that I still fail to understand RxJava is: I failed to think in reactive. This was highlighted in this tutorial but at that point in time when I read it, I thought the writer was making a big issue out of nothing.
Change my mindset? Nah, it’s an easy thing. Coding it is the hard part.
How wrong was I.
In order to help you guys avoid the same mistake that I did, first thing that you need to do is to change your mindset. Change your mindset from : ‘The earth’s gravity’s is pulling everything in’ , to ‘The earth’s gravity is pushing everything out’.
OK, maybe not really accurate, but hope you get my point. This is the kind of mindset change that you need. Only after you’ve successfully changed your mindset, then I think it would make much more sense to you when you read all the RxJava tutorials.
Here’s some of RxJava tutorials that I can recommend:
- The introduction to Reactive Programming you’ve been missing
- Getting Started With ReactiveX on Android
- RxAndroid Basics
- Grokking RxJava
My next post on RxJava should include the transformation that I took to change my codes to use SqlBrite.