Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Observable: Generic observable objects for C++

Write declarative, reactive expressions or just implement the observer pattern.

Observable is a self-contained, header-only library that has no depencencies. Drop it somewhere in your include path and you're good to go.

Quick start


#include <iostream>
#include <observable/observable.hpp>

using namespace std;
using namespace observable;

int main()
    auto sub = subject<void(string)> { };
    sub.subscribe([](auto const & msg) { cout << msg << endl; });

    // "Hello, world!" will be printed to stdout.
    sub.notify("Hello, world!");

    auto a = value<int> { 5 };
    auto b = value<int> { 5 };
    auto avg = observe(
                    (a + b) / 2.0f
    auto eq_msg = observe(
                    select(a == b, "equal", "not equal")

    avg.subscribe([](auto val) { cout << val << endl; });
    eq_msg.subscribe([](auto const & msg) { cout << msg << endl; });

    // "10" and "not equal" will be printed to stdout in an
    // unspecified order.
    b = 15;

    return 0;


You can access the documentation here:

What's with the CMake files?

The library uses CMake to build the tests, benchmarks and documentation. You do not need CMake if you don't plan on running the tests or benchmarks.


Bug reports, feature requests, documentation and code contributions are welcome and highly appreciated. Please open an issue or feature request before you start working on any pull request.

Legal and Licensing

The library is licensed under the Apache License version 2.0.

All contributions must be provided under the terms of this license.

Supported compilers

Any relatively recent compiler with C++14 support should work.

The code has been tested with the following compilers:

  • MSVC 15 (Visual Studio 2017)
  • MSVC 14 (Visual Studio 2015)
  • GCC 5, 6, 7
  • Clang 3.6, 3.8
  • AppleClang 9.1

Build status

Visual Studio 2017 builds:

  • win32 15 build C++14 (32 bit, C++14)
  • win64 15 build C++14 (64 bit, C++14)
  • win32 15 build C++17 (32 bit, C++17)
  • win64 15 build C++17 (64 bit, C++17)

Visual Studio 2015 builds:

  • win32 14 build (32 bit, C++14)
  • win64 14 build (64 bit, C++14)

Linux (GCC, Clang) and OS X (Clang) builds:

  • travis build (64 bit)


Generic observable objects and reactive expressions for C++








No releases published


No packages published