sort of social aspect - friendship, feed, liking, commenting • Competition aspect - taking part in contests • Maintaining motivation - sending reminders about inactivity • Gamification - user can get badge for running 3 days in a row • Sport performance prediction, based on workout history, ML?
String topic; }; public interface Subscriber { void handleEvent(Event event); }; public interface PubSub { void publish(Event event); void subscribe(String topic, Subscriber subscriber); } OK I am just playing with you :D
_} = event_data) do event_data |> Event.new() |> @adapter.publish() end def subscribe(subsriber \\ self(), topic) do @adapter.subscribe( subsriber, topic ) end end
) finishes workout and upload gpx file to our backend • This is an example of deep action, looks simple from UI under the hood is complex • After activity is uploaded, various submodules update they state
with {:ok, activity} <- insert_activity(params), with {:ok, _notification} <- send_notification(activity), with {:ok, _feed} <- add_to_feed(activity), with {:ok, _summary} <- update_monthly_summary(activity) with {:ok, _athlete} <- recalculate_athlete_performance(activity) with {:ok, _athlete_reminder} <- reset_inactive_reminders(activity) end) end end
with {:ok, activity} <- insert_activity(params), with {:ok, _notification} <- send_notification(activity), with {:ok, _feed} <- add_to_feed(activity), with {:ok, _summary} <- update_monthly_summary(activity) with {:ok, _athlete} <- recalculate_athlete_performance(activity) with {:ok, _athlete_reminder} <- reset_inactive_reminders(activity) end) end end
with {:ok, activity} <- insert_activity(params), with {:ok, _notification} <- send_notification(activity), with {:ok, _feed} <- add_to_feed(activity), with {:ok, _summary} <- update_monthly_summary(activity) with {:ok, _athlete} <- recalculate_athlete_performance(activity) with {:ok, _athlete_reminder} <- reset_inactive_reminders(activity) end) end end
do email = SP.Web.Mailing.Recipients.email_for(recipient_id) content = SP.Web.Mailing.build_email(:running, distance) SP.Web.Mailing.send_email(email, content) end end
do IO.outs("Great work dude!!!!oneone") :ok end def handle_event(%ActivityTracked{activity_id: activity_id, type: :swimming}) do raise ArgumentError, "Lol, u can't even swim man!!!!" end end
do IO.outs("Great work dude!!!!oneone") :ok end def handle_event(%ActivityTracked{activity_id: activity_id, type: :swimming}) do raise ArgumentError, "Lol, u can't even swim man!!!!" end end Lol Handler, u know nothing about me!