diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index f08baa5..8fa40bd 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -10,17 +10,17 @@ The retrieval of messages has the following calls: -1) Initial Sync (or Cache Miss Detection and Full Sync) -2) Periodic Retrieve (Incremental Sync) -3) User Scrolls Up - Polling (On-Demand Fetching for Older Messages) +1. Initial Sync (or Cache Miss Detection and Full Sync) +2. Periodic Retrieve (Incremental Sync) +3. User Scrolls Up - Polling (On-Demand Fetching for Older Messages) Messages on the frontend will have a pile structure based on dates. Meaning, the frontend will keep the latest messages and will drop older ones. Call number 1 will populate this pile. This call will be called when the app is initialized or if errors are detected. Imagine this pile populates the messages view of a messaging app. -Call number 2 will bring new messages to the previously mentioned pile. +Call number 2 will bring new messages to the previously mentioned pile. -Call number 3 will bring a paginated set of messages for older conversations. The user will select a specific conversation and this call will be triggered to request older messages. +Call number 3 will bring a paginated set of messages for older conversations. The user will select a specific conversation and this call will be triggered to request older messages. -This approach aims to reduce the calls load yet providing a consistent and lightweight approach to handle messages communication between the FE and BE. +This approach aims to reduce the calls load yet providing a consistent and lightweight approach to handle messages communication between the FE and BE. The pile will have a specific configurable cache size criteria based on amount of messages and dates (e.g., the last N messages, messages within the past X days, etc.). @@ -63,20 +63,20 @@ RetrieveMessagesInitial(); } ``` - ### Event channel name: + ```bash RetrieveMessagesInitial ``` ## Periodic Retrieve (Incremental Sync) -This event will retrieve new messages that recently came from the mediator. +This event will retrieve new messages that recently came from the mediator. ### Example input: ```javascript -RetrieveMessagesPeriodic(date="2024-11-20T00:00:00Z"); +RetrieveMessagesPeriodic((date = '2024-11-20T00:00:00Z')); ``` ### Example response: @@ -115,10 +115,10 @@ RetrieveMessagesPeriodic(date="2024-11-20T00:00:00Z"); "status": "error", "error": "No messages to retrieve" } - ``` ### Event channel name: + ```bash RetrieveMessagesPeriodic ``` @@ -130,8 +130,11 @@ This event will retrieve old messages under user demand. ### Example input: ```javascript -RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pollSize=50); - +RetrieveMessagesPaginated( + (did = 'did:peer:12345'), + (date = '2024-11-20T00:00:00Z'), + (pollSize = 50), +); ``` ### Example response: @@ -150,13 +153,12 @@ RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pol { "did": "did:peer:12345", "contact": "Alice", - "message":"Don’t forget the bread!", + "message": "Don’t forget the bread!", "id": 44, "timestamp": "2024-11-19T23:50:00Z" } ] } - ``` ```json @@ -164,10 +166,10 @@ RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pol "status": "error", "error": "Conversation not found" } - ``` ### Event channel name: + ```bash RetrieveMessagesPaginated ```