Skip to content

[Core] Correctly consuming core observables requires knowledge of the internal implementation #38397

Closed

Description

Context

Most of the data in the Core API is exposed as Observables. Many of these observables aren't a sequence of events, but instead represent the latest value/state. These value observables are implemented as shared/multicast replay subjects. As such, consumers of these observables are usually interested in the first emitted value (and may subscribe to future values). In contrast, in consuming an event observable consumers typically care about the whole sequence of values or the latest.

const status$ = from(['init', 'setup', 'start', 'stop']); // hypothetical event stream

const currentStatus = await status$.pipe(last()).toPromise();
const currentAdminClient = await core.elasticsearch.adminClient$.pipe(first()).toPromise();

Problem

When consuming Core API's it's not clear whether you're consuming a replay/value stream or an event stream and the only way to be sure is to read through the internal code.

See: #35429 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Feature:New PlatformTeam:CoreCore services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions