Mastersam07 / Mastersam07/kaisel

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

Open
#64 0 comments 0 reactions 0 assignees View on GitHub
enhancement pkg:kaisel_core
Dominant language
Dart
Stars
69
Forks
2
Avg merge
18m
Merged PRs (30d)
9

Description

`KaiselConfig? 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:

```dart
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` 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>`, so asynchrony is clearly acceptable elsewhere in the pipeline. `RouteInformationParser.parseRouteInformation` is itself async, so the surrounding Flutter API accommodates it.

## Suggestion

```dart
FutureOr?> 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the KaiselConfigCodec.decode declaration and trace how KaiselRouteInformationParser invokes it across the async RouteInformationParser boundary. Check the existing FutureOr> guard handling for precedent. Done means synchronous codecs still work directly and asynchronous codecs can resolve deep links without being silently skipped.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.