Rxohos
Rxohos: Реактивные расширения для openharmony, специфичные привязки для RxJava3.
Этот модуль добавляет минимум классов в RxJava, которые делают написание реактивных компонентов в приложениях openharmony простым и беспроблемным. Более конкретно, он предоставляет планировщик, который планирует выполнение на основном потоке или любом заданном EventRunner.
Observable.just("one", "two", "three", "four", "five")
.subscribeOn(Schedulers.newThread())
.observeOn(OpenHarmonySchedulers.mainThread())
.subscribe(/* an Observer */);
Это выполнит Observable в новом потоке и выдаст результаты через onNext в основном потоке. 3. Наблюдение на произвольном EventRunner Предыдущий пример — это просто специализация более общей концепции: связывание асинхронной коммуникации с циклом сообщений openharmony или EventRunner. Чтобы наблюдать за Observable на произвольном EventRunner, создайте связанный планировщик, вызвав OpenHarmonySchedulers.from:
EventRunner backgroundeventRunner = EventRunner.create("backgroundThread");
Observable.just("one", "two", "three", "four", "five")
.observeOn(OpenHarmonySchedulers.from(backgroundeventRunner))
.subscribe(/* an Observer */)
Это выполнит Observable в новом потоке и выдаст результаты через onNext на том потоке, на котором работает backgroundEventRunner.
Способ 1: Сгенерируйте пакет .har через библиотеку и добавьте пакет .har в папку libs. Добавьте следующий код в начальный gradle: api 'io.reactivex.rxjava3:rxjava:3.0.3' implementation fileTree (dir: 'libs', include: ['.jar', '.har'])
Способ 2: В build.gradle уровня проекта: allprojects{ repositories{ mavenCentral() } }
Добавьте следующий код в начальный gradle:
api 'io.reactivex.rxjava3:rxjava:3.0.3'
implementation 'io.openharmony.tpc.thirdlib:Rxohos:1.0.0'
Copyright 2015 The RxAndroid authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You can comment after Login
Inappropriate content may be displayed here and will not be shown on the page. You can check and modify it through the relevant editing function
If you confirm that the content does not involve inappropriate language/advertisement redirection/violence/vulgar pornography/infringement/piracy/false/insignificant or illegal content related to national laws and regulations, you can click submit to make an appeal, and we will handle it as soon as possible.
Comments ( 0 )