skiptools / skiptools/skip-model

Initial `.sink` or `.map` doesn't fire for optional @Published properties if they start at `nil`

Open
#12 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
6
Forks
6
Avg merge
1h 39m
Merged PRs (30d)
3

Description

If you have a
@Published var email: String? = nil or any optional that starts at nil, .sink will emit a value on iOS but not on Skip transpiled Android.

class Manager: ObservableObject {
  static let shared = Manager()
  private var subscribers: Set<AnyCancellable> = []
  private init() {
    self.$email.sink { e in
      print("New email: \(e ?? "nil")")
    }
    .store(in: &subscribers)
    
    DispatchQueue.main.async {
      self.email = nil // Emits value on both platforms
    }
  }
  @Published var email: String? = nil // Initially emits nothing on Android
}

struct AlertPlayground: View {
  
  @ObservedObject var manager = Manager.shared

Expected output (how it works on iOS:

New email: nil
New email: nil

Actual output (initially doesn't emit a value)

New email: nil

Context from Slack: https://skiptools.slack.com/archives/C078X69G8F2/p1748547032624249?thread_ts=1748494655.362589&cid=C078X69G8F2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @Published implementation and reproduce the Manager example with an optional property initialized to nil on the Skip Android target, comparing it with iOS behavior. Trace the initial subscription and the later self.email = nil assignment; done means both platforms emit "New email: nil" twice.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.