In order to prepare for this change, you will need to update the artifact ID for the next release. Instead of releasing under the usual
com.pyamsoft.pydroid
or similar artifact groups, it will be released under com.github.pyamsoft.pydroid
. The same transition goes for Cachify and Highlander as well, which will be getting a new com.github
prefixed artifact group. This will not change the package name.With this change comes some important news about the next version of PYDroid, which will be a new major version - 23.
A major change is coming for how
UiViewModel
classes work with regards to creating a component. Before, you would have created the following kind of ViewModelNotice how the ViewModel is strictly tied to one kind of ViewEvent, and knows how to handle all of those ViewEvent messages itself? This was largely nonsensical - as a ViewModel would not be connected to a ViewEvent publisher without wiring it up to the Component mindset via
createComponent
, which means that there would be a UiController present. This also led to issues that made it difficult to re-use a ViewModel with only a partial set of UiViews, as there would be ViewEvents which, in the context of the Component used, would never be called, but the ViewModel required handling it anyway, which was a code smell.The new way in version 23 and onward will significantly change the ViewModel and createComponent calls in a few very important ways. First is that the UiViewModel no longer requires a strict ViewEvent type to be provided as part of the class signature, and as a result, will no longer support the
handleViewEvent
method.The second significant change is that when creating a component via the
createComponent
function, a controller parameter is now explicitly required. The controller can be anything that inherits the UiController<C : UiControllerEvent>
interface. You can either have your Android Controller class (Activity or Fragment for example) inherit this interface, or use the convenient inline method newUiController
which creates an anonymous controller. The inline method is useful when a single Android Controller class handles different UiControllerEvent messages.By changing component creation in this way, the UiController now correctly drives all interactions between its individual layers. A UiView publishes a ViewEvent to the Controller, which handles it in the trailing lambda of
createComponent
. In many cases, this ViewEvent will be call to a UiViewModel method, which can set UiState, or publish a ControllerEvent. The ControllerEvent is then handled by the controller passed into the createComponent
method. This allows you to bind the same ViewModel to multiple different ViewEvent types, since the ViewEvent class type used in the trailing lambda will be decided by the kinds of UiViews that you pass to the function.PYDroid 23 still has a ways to go before it is ready for release, but keep in mind that these changes will be coming soon. Because it is a major code base overhaul, this release will not be backwards compatible, so you may have to invest some time to migrate apps over to the new version. I was able to migrate all of my applications in a single day, though your time spent may change based on the size of your application. If you want to get a head start, you can pull a SNAPSHOT version off of JitPack.
========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?
Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com
Follow my Facebook Page
Check out my code on GitHub
=========================