daxcurson / ampflower

Music player for the Ampache server
GNU General Public License v3.0
3 stars 0 forks source link

Rework search by query #28

Open daxcurson opened 2 years ago

daxcurson commented 2 years ago

Unexpectedly, I found that a mapping method over a LiveData object can be triggered by way of a Transformations:

Transformations.switchMap(dataSourceFactory.getNetworkStatus(), NetAlbumsPageKeyedDataSource::getNetworkState);

The switchMap allows to invoke the method in the second parameter for a change in the observed object (in the first parameter). This can be used to trigger searches on the search string, to replace the current method where a new datasource is created for each change in the search string.