You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2023-02-11-dev-diaries-episode-1.md
+13-11Lines changed: 13 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Another issue we have is despite having a lot of tests it's hard to be sure that
28
28
29
29
We could just risk it and fix problems as we discover them but that sounds like a lot of stress too.
30
30
31
-
A few years ago my friend [Tom](https://software.tomseldon.co.uk/blog/) (He's more focused on racing cars these days but I've linked to his technical writing blog which is still really good) created a section in the app for dev tooling to live which is super handy. A new tool was added which had one job…
31
+
A few years ago my friend [Tom](https://www.tomseldon.co.uk) created a section in the app for dev tooling to live which is super handy. A new tool was added which had one job…
32
32
33
33
## The Task
34
34
@@ -55,12 +55,12 @@ _isNewTransformerEnabled () {
55
55
Then in each repository (the layer above the transformer) we call this method to see if we should use the old or new transformer
Consumers of the feature flag service call `isEnabled()` which gets the status of the flag. If an override exists it ignores the original setting and instead resolves the override. We don't check for falsy because we might want to return false from the overrides.
86
86
87
-
88
87
```javascript
89
88
isEnabled (flagName) {
90
89
if (this._overrides[flagName] !==undefined) {
@@ -140,8 +139,10 @@ Imagine this with promises too and its a bit of a mind ~~f*ck~~. So a ranty walk
140
139
Instead we use promises as they were meant to be used and chain them. (Why didn't I do it this way to start with?!). Starting off we get the topics then with that we map over the resolved array to get more info about each topic like so:
This uses the reduce function and starts off with a resolved promise, it then chains subsequent promises for each job so we only run the next job if the previous one resolved.
This is pretty similar to the mock code earlier. We disable the flag, test, enable then test again. To compare the two results we use `JSON.stringify()` which I got from [Samantha's Blog](https://www.samanthaming.com/tidbits/33-how-to-compare-2-objects/) which advised this would do the job albeit with performance and ordering issues but both of these weren't a concern for this, we just wanted to know that they were the same output.
0 commit comments