# otto **Repository Path**: HarmonyOS-tpc/otto ## Basic Information - **Project Name**: otto - **Description**: Otto is an event bus designed to decouple different parts of your application while still allowing them to communicate efficiently. - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2021-04-01 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-communication **Tags**: None ## README ## otto ## Introduction Otto is an event bus designed to decouple different parts of your application while still allowing them to communicate efficiently. Forked from Guava, Otto adds unique functionality to an already refined event bus as well as specializing it to the openharmony platform. ### Features: #### Receiving messages on main thread using Bus #### Receiving messages on worker thread using Bus ## Usage Instruction 1) Register to Bus 2) Post messages from UI thread 3) Catch messages in UI thread ```java BusProvider.getBus().register(this); BusProvider.getBus().post(new Message("From Other Thread")); @Subscribe public void receiveMessage(Message msg){ System.out.println("Bus Message Received: "+ msg.getMsg()); } ``` ## Installation instruction ### Method 1: Generate the .har package through the library and add the .har package to the libs folder. 1. Add the .har package to the lib folder. 2. Add the following code to the gradle of the entry: implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) ### Method 2: ```gradle allprojects { repositories { mavenCentral() } } dependencies { implementation 'io.openharmony.tpc.thirdlib:otto:1.0.1' } ``` ## License ------- Copyright 2012 Square, Inc. Copyright 2010 Google, Inc. 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.