Skip to content

Proposal to change the way telemetry is initalized  #289

@tobrun

Description

@tobrun

Some thoughts capturing from a comment on the Telemetry module PR.

Telemetry is currently initialized with:

MapboxTelemetry telem = MapboxTelemetry.getInstance();
telem.initalize(context, accessToken, locationProvider);

I'm not a big fan of having both a getInstance and initalizer method as it defeats the purposes of those methods separately and I feel this is thread unsafe as it can lead to race conditions.

I'm thinking this can be solved in two ways:
We either change the underlying code to add parameters to getInstance and setting those as class members + referencing those solely through INSTANCE class member. An example of this in Mapbox.java

Other idea is to separate the concerns of this class into different components using a design patterns (eg. a factory pattern could serve as a wrapper around the paremeters?). This should remove the requirement of the initialization method.

cc @zugaldia

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions