Skip to content

Commit

Permalink
#58 envent handler comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xeronimus@gmail.com authored and xeronimus@gmail.com committed Jun 7, 2020
1 parent c68b329 commit e5bb7da
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 16 deletions.
35 changes: 20 additions & 15 deletions server/docu/commandAndEventDocu.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Poinz Command and Event Docu
This is an autogenerated docu. 6/7/2020, 12:23:12 PM
This is an autogenerated docu. 6/7/2020, 4:05:11 PM

## Commands

Expand Down Expand Up @@ -818,7 +818,7 @@ Produced by: **[addStory](#addStory)** **[selectStory](#selectStory)**
Description

```text
Store id of given story as "selectedStory"
```


Expand All @@ -831,7 +831,7 @@ Produced by: **[changeStory](#changeStory)**
Description

```text
Title and/or Description of story changed
```


Expand All @@ -844,7 +844,7 @@ Produced by: **[clearStoryEstimate](#clearStoryEstimate)**
Description

```text
Removes a previously set estimation value on the given story for the given user
```


Expand All @@ -857,7 +857,10 @@ Produced by: **[createRoom](#createRoom)**
Description

```text
A room was created. Creates a new default room object
@param room
@param eventPayload
@return {}
```


Expand All @@ -870,7 +873,7 @@ Produced by: **[createRoom](#createRoom)** **[joinRoom](#joinRoom)**
Description

```text
Adds user object with given userId to "users" list on room
```


Expand Down Expand Up @@ -909,7 +912,7 @@ Produced by: **[deleteStory](#deleteStory)**
Description

```text
Removes matching story from "stories" list in room
```


Expand All @@ -922,7 +925,7 @@ Produced by: **[giveStoryEstimate](#giveStoryEstimate)**
Description

```text
Stores the given estimation value on the story for the given user
```


Expand Down Expand Up @@ -950,7 +953,7 @@ Produced by: **[giveStoryEstimate](#giveStoryEstimate)**
Description

```text
Stores consensus estimation value (that everybody agreed on) on story.
```


Expand All @@ -963,7 +966,7 @@ Produced by: **[joinRoom](#joinRoom)** **[toggleExclude](#toggleExclude)**
Description

```text
Sets "excluded" flag on user to true
```


Expand All @@ -976,7 +979,8 @@ Produced by: **[kick](#kick)**
Description

```text
removes user from "users" list
removes estimations on all stories that were given by user
```


Expand All @@ -989,7 +993,7 @@ Produced by: **[leaveRoom](#leaveRoom)**
Description

```text
Marks user as "disconnected".
```


Expand All @@ -1002,7 +1006,8 @@ Produced by: **[leaveRoom](#leaveRoom)**
Description

```text
removes user from "users" list
removes estimations on all stories that were given by user
```


Expand All @@ -1015,7 +1020,7 @@ Produced by: **[newEstimationRound](#newEstimationRound)**
Description

```text
Clears all estimations on story, sets "revealed" flag to false and erases "consensus"
```


Expand All @@ -1028,7 +1033,7 @@ Produced by: **[toggleExclude](#toggleExclude)**
Description

```text
Sets "excluded" flag on user to false
```


Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/connectionLost.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Marks user as "disconnected".
*/
const connectionLostEventHandler = (room, eventPayload) => {
const matchingUser = room.getIn(['users', eventPayload.userId]);
if (matchingUser) {
Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/consensusAchieved.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Stores consensus estimation value (that everybody agreed on) on story.
*/
const consensusAchievedEventHandler = (room, eventPayload) =>
room.setIn(['stories', eventPayload.storyId, 'consensus'], eventPayload.value);

Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/excludedFromEstimations.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Sets "excluded" flag on user to true
*/
const excludedFromEstimationsEventHandler = (room, eventPayload) =>
room.updateIn(['users', eventPayload.userId], (user) => user.set('excluded', true));

Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/includedInEstimations.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Sets "excluded" flag on user to false
*/
const includedInEstimationsEventHandler = (room, eventPayload) =>
room.updateIn(['users', eventPayload.userId], (user) => user.set('excluded', false));

Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/joinedRoom.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Immutable from 'immutable';

/**
* Adds user object with given userId to "users" list on room
*/
const joinedRoomEventHandler = (room, eventPayload) =>
room.setIn(['users', eventPayload.userId], new Immutable.Map({id: eventPayload.userId}));

Expand Down
4 changes: 4 additions & 0 deletions server/src/eventHandlers/kicked.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* removes user from "users" list
* removes estimations on all stories that were given by user
*/
const kickedEventHandler = (room, eventPayload) =>
room
.update('stories', (stories) =>
Expand Down
4 changes: 4 additions & 0 deletions server/src/eventHandlers/leftRoom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* removes user from "users" list
* removes estimations on all stories that were given by user
*/
const leftRoomEventHandler = (room, eventPayload) =>
room
.update('stories', (stories) =>
Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/newEstimationRoundStarted.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Immutable from 'immutable';

/**
* Clears all estimations on story, sets "revealed" flag to false and erases "consensus"
*/
const newEstimationRoundStartedEventHandler = (room, eventPayload) =>
room
.setIn(['stories', eventPayload.storyId, 'estimations'], new Immutable.Map())
Expand Down
7 changes: 6 additions & 1 deletion server/src/eventHandlers/roomCreated.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Immutable from 'immutable';

// here we create the room object
/**
* A room was created. Creates a new default room object
* @param room
* @param eventPayload
* @return {*}
*/
const roomCreatedEventHandler = (room, eventPayload) =>
Immutable.fromJS({
id: eventPayload.id,
Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/storyChanged.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Title and/or Description of story changed
*/
const storyChangedEventHandler = (room, eventPayload) =>
// for now, the changeStory command must contain always both attributes (see validation schema)
// so we can just overwrite both
Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/storyDeleted.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Removes matching story from "stories" list in room
*/
const storyDeletedEventHandler = (room, eventPayload) =>
room.removeIn(['stories', eventPayload.storyId]);

Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/storyEstimateCleared.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Removes a previously set estimation value on the given story for the given user
*/
const storyEstimateClearedEventHandler = (room, eventPayload) =>
room.removeIn(['stories', eventPayload.storyId, 'estimations', eventPayload.userId]);

Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/storyEstimateGiven.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Stores the given estimation value on the story for the given user
*/
const storyEstimateGivenEventHandler = (room, eventPayload) =>
room.setIn(
['stories', eventPayload.storyId, 'estimations', eventPayload.userId],
Expand Down
3 changes: 3 additions & 0 deletions server/src/eventHandlers/storySelected.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Store id of given story as "selectedStory"
*/
const storySelectedEventHandler = (room, eventPayload) =>
room.set('selectedStory', eventPayload.storyId);

Expand Down

0 comments on commit e5bb7da

Please sign in to comment.