TikTok interview question

Asked to implement publisher subscriber