Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

WebView to Native Message Bridge

Medium
CodingHash TablesArraysStringsAsked 1 times

Bridge Messages to Native Handlers

Implement a bridge that receives messages from a WebView and routes them to native handlers. Messages arrive as JSON strings with type, id, and payload. If a handler for a message type is not yet registered, queue the message and deliver it later in FIFO order when that handler becomes available.

Constraints

  • 1 <= len(messages) <= 10^4
  • Each message contains valid JSON with keys type, id, and payload
  • Message id values are unique
  • Handler registration may happen multiple times
  • Preserve FIFO order for queued messages of the same type

You are practicing as a guest. Sign up free to run your code against the sample data. Your draft stays right here.

Sign up freeI have an account
def solve(rows):
    counts = {}
    for row in rows:
        ...
    return result
Sign up to unlock solutions
Next questions
RakutenReact Native Bridge InternalsMediumTuringReact Native Bridge OptimizationMediumDiscordReact Native Bridge and JSIHard
Python 3.10