{"id":3610,"url":"https://github.com/coshx/drekkar","last_synced_at":"2026-01-14T12:18:47.352Z","repository":{"id":66626312,"uuid":"46528016","full_name":"coshx/drekkar","owner":"coshx","description":"An Android event bus for WebView and JS.","archived":false,"fork":false,"pushed_at":"2016-02-25T02:15:07.000Z","size":331,"stargazers_count":26,"open_issues_count":0,"forks_count":1,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-08-03T20:48:24.034Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://coshx.github.io/drekkar/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coshx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-20T00:04:33.000Z","updated_at":"2025-07-15T03:19:47.000Z","dependencies_parsed_at":"2023-05-09T14:03:34.264Z","dependency_job_id":null,"html_url":"https://github.com/coshx/drekkar","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/coshx/drekkar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coshx%2Fdrekkar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coshx%2Fdrekkar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coshx%2Fdrekkar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coshx%2Fdrekkar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coshx","download_url":"https://codeload.github.com/coshx/drekkar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coshx%2Fdrekkar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:46.353Z","updated_at":"2026-01-14T12:18:47.332Z","avatar_url":"https://github.com/coshx.png","language":"Java","funding_links":[],"categories":["Pub/Sub","Libraries","Libs","库"],"sub_categories":["Utility","\u003cA NAME=\"EventBus\"\u003e\u003c/A\u003eEventBus","[](https://github.com/JStumpp/awesome-android/blob/master/readme.md#utility)框架"],"readme":"![Logo](https://raw.githubusercontent.com/coshx/drekkar/master/logo.png)\n\n[![Release](https://jitpack.io/v/coshx/drekkar.svg)](https://jitpack.io/#coshx/drekkar)\n\n[![Join the chat at https://gitter.im/coshx/drekkar](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/coshx/drekkar?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n**An event bus for sending messages between WebView and embedded JS. [Alter ego of Caravel](https://github.com/coshx/caravel).**\n\n## Features\n\n* Easy, fast and reliable event bus system\n* Multiple bus support\n* Multithreading support\n* WebView ~\u003e JavaScript supported types:\n  - `Bool`\n  - `Int`\n  - `Float`\n  - `Double`\n  - `String`\n  - Any list (using types in this list, including maps)\n  - Any map (using types in this list, including lists)\n* JavaScript ~\u003e Android supported types:\n  - `Boolean`\n  - `Int`\n  - `Float` (available as a `Double`)\n  - `String`\n  - `Array` (available as a `List`)\n  - `Object` (available as a `Map`)\n\n## Installation\n\n### Using JitPack\n\nMerge this code into your root build.gradle file:\n\n```groovy\nallprojects {\n\trepositories {\n\t\tmaven { url \"https://jitpack.io\" }\n\t}\n}\n```\n\nThen, add this dependency to your module:\n\n```groovy\ndependencies {\n    compile 'com.github.coshx:drekkar:v0.1.1'\n}\n```\n\nFinally, you need to load the internal JS script Drekkar is using to make magic happen. You can either use `R.draw.drekkar_min` or add the minified JS script from [the latest release](https://github.com/coshx/drekkar/releases) to your `raw` resources. This script must be loaded in any webpage you are using Drekkar.\n\n### Using as a submodule\n\nClone this repo and add the `drekkar` module to your workspace.\n\n## Get started\n\nDrekkar allows developers to communicate between their `WebView` and the embedded JS. You can send any kind of message between these two folks.\n\nHave a glance at this super simple sample. Let's start with the Android part:\n\n```java\nclass MyActivity extends Activity {\n    WebView webView;\n\n    void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        webView = (WebView) findViewById(R.id.my_webview_id);\n\n        // Prepare your bus before loading your web view's content\n        Drekkar.getDefault(this, webView, new WhenReady() {\n            @Override\n            public void run(EventBus bus) {\n                // In this scope, the JS endpoint is ready to handle any event.\n                // Register and post your events here\n                List\u003cInteger\u003e list = new ArrayList\u003c\u003e();\n                list.add(1);\n                list.add(2);\n                list.add(3);\n\n                bus.post(\"MyEvent\", list);\n\n                MyActivity.this.bus = bus; // You can save your bus for firing events later\n            }\n        });\n\n        // ... Load web view's content there\n    }\n}\n```\n\nAnd now, in your JS:\n\n```javascript\nvar bus = Drekkar.getDefault();\n\nbus.register(\"AnEventWithAString\", function(name, data) {\n    alert('I received this string: ' + data);\n    bus.post(\"AnEventForAndroid\");\n});\n```\n\nAnd voilà!\n\n## Porting your app from Caravel to Drekkar\n\nSuper duper easy. Just use the same codebase and use the JS script from Drekkar. Finally, add this after having loaded the Drekkar script:\n\n```javascript\nvar Caravel = Drekkar;\n```\n\n## Troubleshooting\n\n### 😕 Sometimes the bus is not working?!\n\nFirstly, ensure you are using the bus correctly. Check if you are unregistering the bus when exiting the controller owning your web component. Use the [unregister method for this]().\n\nDrekkar automatically cleans up any unused bus when you create a new one. However, this operation is run in the background to avoid any delay on your side. So, a thread collision might happen if you have not unsubscribed your bus properly.\n\nHowever, if you think everything is good with your codebase, feel free to open a ticket.\n\n### What object should I use as a subscriber?\n\nA subscriber could be any object **except the watched target**. We recommend to use the activity/current context as a subscriber (it is a common pattern).\n\n### Reserved names\n\n`DrekkarInit` is an internal event, sent by the JS part for running the `WhenReady` object.\n\nAlso, the default bus is named `default`. If you use this name for a custom bus, Drekkar will automatically switch to the default one.\n\nFinally, Drekkar names its JS interface `DrekkarWebViewJSEndpoint`.\n\n### Keep in mind event and bus names are case-sensitive.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoshx%2Fdrekkar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoshx%2Fdrekkar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoshx%2Fdrekkar/lists"}