• Stars
    star
    23
  • Rank 933,146 (Top 20 %)
  • Language
    Scala
  • License
    GNU General Publi...
  • Created almost 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small and effective event-handling library for Scala

Wire Signals

or Yet Another Reactive Library for Scala

Scala CI

About two thirds of Wire Android code is written in Scala making it unique among Android apps - most of them being implemented in Java and/or Kotlin. Wire is a messenger and as such it must be very responsive: it has to quickly react to any events coming from the backend, as well as from the user, and from the Android OS itself. The Wire Android team developed its own implementation of event streams and "signals" - special event streams with caches holding the last propagated value. They proved to be a very flexible and concise way of handling events all over the Scala code in Wire.

Wire Signals are used extensively in our application, from fetching and decoding data from another device to updating the list of messages displayed in a conversation.

How to use

To include wire-signals in your project, add this to your library dependencies in sbt:

libraryDependencies += "com.wire" %% "wire-signals" % "1.0.0"

Currently wire-signals work with Scala 2.11 (because Android), 2.12, 2.13, and it's ready for Scala 3.

Similarly, you can add wire-signals-extensions to get some additional functionality. The reason for splitting the library into two is that the core library is enough to perform the main task of event streams and signals, which is to transport events across the app. For some users this might be all they need and so they will be interested more in lack of additional dependencies, small codebase, and performance. The core library is dependent in production only on the standard Scala library.

In short, you can create a SourceSignal somewhere in the code:

val intSignal = Signal(1) // SourceSignal[Int] with the initial value 1
val strSignal = Signal[String]() // initially empty SourceSignal[String]

and subscribe it in another place:

intSignal.foreach { number => println("number: $number") }
strSignal.foreach { str => println("str: $str") }

Now every time you publish something to the signals, the functions you provided above will be executed, just as in case of a regular event stream...

scala> intSignal ! 2
number: 2

... but if you happen to subscribe to a signal after an event was published, the subscriber will still have access to that event. On the moment of subscription the provided function will be executed with the last event in the signal if there is one. So at this point in the example subscribing to intSignal will result in the number being displayed:

> intSignal.foreach { number => println("number: $number") }
number: 2

but subscribing to strSignal will not display anything, because strSignal is still empty. Or, if you simply don't need that functionality, you can use a standard EventStream instead.

You can also of course map and flatMap signals, zip them, throttle, fold, or make any future or an event stream into one. With a bit of Scala magic you can even do for-comprehensions:

val fooSignal = for {
 number <- intSignal
 str    <- if (number % 3 == 0) Signal.const("Foo") else strSignal
} yield str

If you want to know more about how we use it:

Contributors

More Repositories

1

wire-android

☎️ Wire for Android
Scala
2,572
star
2

wire-server

πŸ‡ͺπŸ‡Ί Wire back-end services
Haskell
2,563
star
3

wire

〰️ Overview of the open source code for Wire
2,307
star
4

wire-webapp

πŸ‘½ Wire for web
TypeScript
1,103
star
5

wire-desktop

πŸ’» Wire for desktop
TypeScript
1,053
star
6

proteus

Axolotl Protocol Implementation
Rust
412
star
7

wire-ios-sync-engine

iOS synchronization library for Wire
Swift
149
star
8

wire-avs

Audio Video Signaling (AVS)
C
134
star
9

wire-server-deploy

Code to install/deploy wire-server (on kubernetes)
HCL
88
star
10

lithium

Wire Services JDK
Java
79
star
11

coax

A (barely working) native Wire client for Unix
Rust
75
star
12

wire-web-packages

Collection of npm modules created by Wire's web team.
TypeScript
59
star
13

wire-android-sync-engine

Sync library for Android.
Scala
59
star
14

bot-sdk-node

πŸ€–
JavaScript
58
star
15

pqproteus

PQProteus
Rust
57
star
16

echo-bot

Echo bot
Java
56
star
17

websql

Encrypted SQLite database for the browser and Node.js
TypeScript
56
star
18

cryptobox

High-level API with persistent storage for proteus
Rust
52
star
19

melissa

Messaging Layer Security (MLS) implementation in Rust
Rust
52
star
20

wire-ios-link-preview

🏷 Open Graph data parser used to generate link previews
Swift
48
star
21

wire-android-reloaded

πŸ€– The new Wire client for Android
Kotlin
46
star
22

kalium

🍌 An SDK for creating Wire clients on Android and JVM. Expanding to iOS and Web.
Kotlin
41
star
23

carthage-gradle-plugin

Gradle plugin for Carthage
Kotlin
36
star
24

proteus.js

Axolotl protocol implementation for JavaScript
JavaScript
36
star
25

libsodium-neon

Node.js bindings to rust_sodium.
Rust
36
star
26

generic-message-proto

Protocol definition for generic messages.
Scala
35
star
27

hkdf

HKDF implementation (RFC 5869)
Rust
29
star
28

cryptobox-c

C-FFI to cryptobox
C
29
star
29

wire-ios-data-model

Core Data model and entity classes
Swift
28
star
30

cryptobox-haskell

Cryptobox Haskell FFI
Haskell
27
star
31

wire-ios-cryptobox

Swift
22
star
32

wire-ios-transport

Objective-C
22
star
33

wire-ios-ziphy

https://wire.com
Swift
22
star
34

wire-ios-share-engine

Share extension framework for iOS
Swift
22
star
35

node-addressbook

Node.js module providing access to the macOS address book
C++
18
star
36

wire-ios

πŸ“± Wire for iOS (iPhone and iPad)
Swift
18
star
37

cryptobox.js

JavaScript
17
star
38

core-crypto

MLS/Proteus multiplexer abstraction with encrypted persistent storage in Rust
Rust
17
star
39

cryptobox-jni

JNI bindings for cryptobox with support for cross-compilation to Android.
Java
17
star
40

wire-ios-images

πŸ—» Framework to perform rotation and scaling of images
Objective-C
16
star
41

wire-ios-system

Swift
15
star
42

github-action-wire-messenger

JavaScript
15
star
43

wire-ios-utilities

Swift
14
star
44

saml2-web-sso

Library and example web app for the SAML Web-based SSO profile.
Haskell
14
star
45

wire-ios-mocktransport

Objective-C
13
star
46

wire-ios-canvas

Canvas is a component for painting and composing pictures
Swift
13
star
47

wire-ios-protos

πŸ“œ obj-c autogenerated classes from https://github.com/wireapp/generic-message-proto protocol buffer definitions
Swift
13
star
48

wire-emails

Templates for sending emails for Wire
HTML
12
star
49

wire-ios-testing

Objective-C
12
star
50

wire-ios-request-strategy

iOS synchronization base interfaces for Wire
Swift
12
star
51

wire-ios-message-strategy

iOS synchronization of messages for Wire
Swift
11
star
52

backend-api-protobuf

Scala
11
star
53

anna-bot

Rosie chatbot for Wire
Java
11
star
54

antiscroll-2

macOS Lion-styled scrollbars for DOM elements.
HTML
11
star
55

servant-uverb

deprecated prototype implementation of https://github.com/haskell-servant/servant/pull/1314
Haskell
11
star
56

libsodium.js

libsodium compiled to pure JavaScript, with convenient wrappers
JavaScript
10
star
57

wire-web-store-engine

Provider for the following storage engines: File, IndexedDB, Memory & LocalStorage.
JavaScript
10
star
58

wire-account

Account verifications and forgotten passwords (https://wire-account-staging.zinfra.io/forgot/).
TypeScript
10
star
59

wire-web-core

Collection of npm modules created by Wire's web team.
TypeScript
9
star
60

wire-web-queue-priority

A promise based dynamic priority queue runner.
JavaScript
9
star
61

libsodium

A modern and easy-to-use crypto library.
C
9
star
62

avs-ios-binaries

AVS binaries for iOS
Objective-C
9
star
63

ansible-cassandra

Ansible role to install an Apache Cassandra cluster
Shell
9
star
64

picklejar-engine

A JUnit 5 Test engine for running cucumber test in Java. Suitable for very big test suite projects.
Java
8
star
65

libsodium-native

C++
8
star
66

alert-bot

Broadcasts alerts
Java
8
star
67

backup-export-tool

Tool which exports Wire client's backups and generates PDF from it.
Java
8
star
68

wire-audio-files

Audio notifications files for Wire application.
Scala
8
star
69

wire-web-config-default

7
star
70

cryptobox-ios

iOS binaries for cryptobox
Shell
7
star
71

recording-bot

Java
7
star
72

wire-android-translations

☎️ Non-english strings for Wire android client
7
star
73

wire-theme

CSS
6
star
74

scala-utils

JVM friendly utility classes for Scala, including signals and threading.
Scala
6
star
75

bazinga64

Base64 encoding and decoding with ASCII string representation. Works with Node.js and modern browsers.
JavaScript
6
star
76

broadcast-bot

Broadcast Channel for Wire
Java
6
star
77

wire-ios-shared-resources

Shared resources used by the Wire iOS application
Groovy
6
star
78

mls-client

Rust
5
star
79

fido2-hackathon

Linkdump for the FIDO2/Webauthn/2FA Hackathon
5
star
80

rusty-jwt-tools

Tools for manipulating JSON Web Tokens, JWS, JWE, and JWK in Rust
Rust
5
star
81

roman

Lithium proxy for Wire
Java
5
star
82

gitlab

GitLab integration for Wire
Java
5
star
83

wire-server-deploy-networkless

Notes and code for installing wire-server-deploy in an environment without internet
Shell
5
star
84

ldap-scim-bridge

Command-line translator between LDAP and SCIM systems.
Haskell
5
star
85

babel-plugin-remove-jsx-attributes

Babel plugin for removing attributes from JSX elements
JavaScript
5
star
86

charon

Proxy mapping requests from Slack bots to Roman and back
Python
5
star
87

wire-web-ets

End-to-end Test Service (ETS) for Wire's test automation suite
TypeScript
5
star
88

don-bot

Don - Wire meta bot
Java
4
star
89

wire-docs

Documentation of Wire for Developers and Operators
Nix
4
star
90

wire-ios-notification-engine

Notification extension framework for iOS
Swift
4
star
91

grunt-npm-bower

Grunt plugin which helps migrating from Bower to npm.
JavaScript
4
star
92

wire-desktop-packages

Collection of npm modules used by Wire's desktop clients.
TypeScript
4
star
93

brand

Brand assets & styleguide content Β· brand.wire.com
HTML
3
star
94

webapp-module-modal

CSS
3
star
95

mls-server

A prototype MLS server (deprecated)
Haskell
3
star
96

prebuilt-webrtc-binaries

Prebuilt binaries for webrtc library
Shell
3
star
97

terraform-hcloud-rke2

HCL
3
star
98

mi

morphing identity
Rust
3
star
99

ansible-minio-archive

minio external playbook
Shell
3
star
100

cryptobox4j

Cryptobox jni optimized for Services
Java
3
star