mplekunov / CalculatorApp

GNU General Public License v3.0
1 stars 0 forks source link

Concurrency #19

Open mplekunov opened 2 years ago

mplekunov commented 2 years ago

Calculator works but only after removing concurrency.... Need to implement thread management which would allow me, once again, to have an app where UI will be on the main thread and all calculation somewhere else... (could use Dispatchers.DEFAULT) coroutine context for "CPU" intensive calculations.

mplekunov commented 2 years ago

Literally have no idea what to do....

Used viewModelScope and launch Coroutine Factory to create new coroutine which will call EvaluateExpression and assign new values to result and expression... Problems: it works as intended... however newly "added" changes to result and expression aren't being shown until I call to show them on "new input" or any other "action" which forces them to be shown... I tried converting everything to LiveData... Same thing. I need to figure out how to update "UI" output and input based on the "new info" received from Coroutine...

mplekunov commented 2 years ago

Currently I literally have 0 clue... No reason to use Async and Await because... from my Understanding they are only used to "access" data inside of the coroutine

mplekunov commented 2 years ago

Well... The only way that I "could" possibly implement concurrency would be by creating Deferred and Deferred<List> for result and expression respectfully and then, using async and await, push them through Expression -> ViewModel -> Editable Input -> Input Adapter -> Clickable...

Why?... well...Editable Input class is responsible for "conversion of input to spannable input"... As such, it is the first place where "viewModel.expression" will be called... So, I have to use await() there before this class will try to "format" expression to spannable.

mplekunov commented 2 years ago

I have around 13 days before I will need to do other things... So... This whole thing looks like pain in the ass and therefore I guess I will have to do other stuff before coming back to this issue.

mplekunov commented 2 years ago

I AM IN DIRE NEED FOR MULTITHREADING.... There is nothing much to say about it... After settings menu all time should be allocated to multithreading/bug fixing