Skip to content

feat: make KaiselConfigCodec.decode return FutureOr so deep-link resolution can be async #64

Description

@Mastersam07

KaiselConfig<R>? decode(Uri) is synchronous, so a deep link whose destination depends on asynchronous state cannot be expressed.

Realistic cases: consulting secure storage before deciding where a link lands, checking a remotely-evaluated feature flag, resolving an entitlement, or reading a cached profile to choose between two stacks.

Concrete impact

An app migrating 28 deep-link destinations got away with it only because every handler happened to be synchronous. To keep it that way safely it had to add a runtime guard, since the failure would otherwise be silent:

final handled = resolve(mapping, builder, uri, isPending: isPending);
if (handled is! bool) {
  logger.error($destination registered an async handler, but decoding is synchronous);
  continue;
}

That check exists purely because the type system allows FutureOr<bool> there while decode cannot await it. A contributor adding an async destination would otherwise get a silently skipped deep link.

Precedent inside kaisel

Guards are already FutureOr<List<R>>, so asynchrony is clearly acceptable elsewhere in the pipeline. RouteInformationParser.parseRouteInformation is itself async, so the surrounding Flutter API accommodates it.

Suggestion

FutureOr<KaiselConfig<R>?> decode(Uri uri);

Sync codecs keep returning a value directly; async ones become expressible. KaiselRouteInformationParser already sits on an async boundary, so the await has somewhere natural to go.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions