grab / grab/grabplatform-sdk-ios

A typo and some feedback on API design

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
13
Forks
2
PR merge metrics
No merged PRs in 30d

Description

` guard error != nil else {
// handle login error
return
}`
I think you mean `guard error == nil else {...}`.

Regarding API design, it's tedious.
You have to check error every step of the way. Singleton may not even exist at all.
No point for nested login, e.g; loadLoginSession followed by login, you are exposing your implementation details for an opportunity at error handling that no one cares.

Nil coalescing to make singleton non-optional, and make calls chainable, e.g.;
`GrabIdPartner.shared.login(presentingViewController: vc).onSuccess { session in ...}.onFailure { error in ...} `

User does not care where you go wrong, and I only care for debug purpose. Provide some debug logging instead of repeated nested unwrapping of both your optionals and weak selfs.

By the way, I'll just inject dependency injection, e.g.; `self?.callback(...)` instead of `guard let self = self`,
it looks more professional.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the login guard shown in the issue and the loadLoginSession/login entry points. Review the proposed chaining, optional handling, dependency injection, and debug logging against the existing SDK API. Done requires an agreed design and implementation scope, but the issue names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
api, mobile
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.