Getting Started with Feature Flags - #1 LaunchDarkly Feature Flags

Fun Fun Function · Beginner ·📰 AI News & Updates ·8y ago

Key Takeaways

LaunchDarkly feature flags implementation for beginners

Full Transcript

good Wednesday morning Beecher flags kind of allows us to beta-test parts of our system it's a technique where we hide parts of our system behind a feature flag and this allows us to roll out to a subset of our users in a gradual manner I am mvj and you are watching function [Music] [Music] this extra Wednesday episode of fun fun function is brought to you by launch directly which is a product that we're going to use when implementing feature flags in this video if you like what you see please do check them out and give them some love for supporting the show alright let's get started the first thing that we're going to do is to create a completely new app and app without feature flags that's the first thing that we're going to do right it's done let's see D into this thing and see if it works and p.m. start oh it's over here you know yeah yes it works excellent let's close that and close exit the development server as the name I used here implies we're going to create a playlist and by what a P by that is basically as an interface that at first used lists a bunch of hard-coded songs let's go alright let's open up app Jas let's get rid of this stuff here and instead just like a list of of of songs here like just Li and then title and one more title to add one title to title three lesser problem I only need to close this list that's it alright let me close this terminal and instead use the integrated terminal in Visual Studio code and let's do anything start to have a look at what our interface looks like after my my edits whoo that's a gorgeous in their face I'm a born designer all right so we want to change this to have some actual hard coded data so let's do in the constructor we're going to assign this state should be like some songs gonna code in some songs I'm actually not gonna code in some songs I've prepared this before I can you know kind of paste in some songs I wrote before so these are some songs that we added to this imaginary playlist here you see that some of them are already in the end of November and some of them are added at the start of December and we want to list them out so this dot state of song stops map and for each zone we are going to have an ally and we're going to display them like that whatever to do check this out this is not allowed before super that's correct I need to call the super before oh cool in doing anything else in classes because classes are annoying unexpected use of name now that's true what would name even be it's supposed to be somewhat named otherwise things would be weird magical all right cool we are now listing their songs next up I want to add some sorting right so I want to think about a problem that I had while I was working at Spotify we had I was not alone and working on the playlist that by any means but a playlist works its way it's it's a list of songs like it's kind of like the the the mental model for it is a mixtape if if you're that all of you remember mixtapes but the general idea is that you add songs and you can rearrange the list and like the list has a specific specific order and when you add something to a playlist just say add and then it will end up at the bottom however for some playlist this works fine if you like or if you're creating a playlist for like a gym or like some nice playlist to send to someone you care about that makes sense but if it's a playlist that is your dumping ground for new and interesting music that you want to want to listen to then it makes a ton more sense to just have the playlist always sorted by recently added and what that is what we're going to add here we're going to add some sorting to it let's just say sort order here and we're going to call a by default it's it's not going to have a sort order it's good that's going to be you know it's gonna be the natural order that that it's coming from the database our hard-coded array alright so what we're going to do is that we're going to before mapping we're going to sort using a sort of function and initially the sorter function is just going to be undefined so if you pass in undefined to sort it's not going to do any sorting okay prove it to you look only one strong stream a river it's not sorted we're going to get to this but before I do I want to do allow we have to fix a little caveat here because the sort function sorts in place this is because the creators of this function in JavaScript are our satan himself so we need to do a slice first this is a very nice way of just making a quick shallow copy of an array so this way we get a new like copy of this array and then we sort that and then we map it so that even though that this sort in place that won't matter because it's a copy all right so the sort order however however mmmmmm if the sort order equals equals equals with say added then we are going to assign sorter to be a function that compares added let's see how we do this I made some some handy notes on how to do this while I was rehearsing this so that you don't think that I'm pulling this out of my brain but or something like that so what we're gonna do is we're gonna do the parse data parse data parse a not added and we're going to compare that to date parse be added you think that this is just gonna parse them out as as a number like a UNIX timestamp or something but this makes them comparable oh I think that will work except that now we are reassigning sorter so let's make it into left instead sort order is not if I know that's true if this dot state dots were Tory that's what we're going for all right cool but nothing is ever signing itself to sort order we need to create some kind of button that does that so let's do that let's create a condom here not is called natural sorting and we are going to create one that is called time sorting on the worse than naming and we're going to do one click here and don't you assign thingamabobs here and you see a function and just going to do like this start set stapes and set that state to sort so order sort order I'm the best typist and we're not set it to add it awesome that might work time sorting I clicked it but nothing is happening let me pull up the inspector see if something happens this is just a warning that we don't care about this these purposes like to check out react here see what the sort order state is so react we can actually expect the state here which is really handy in the react Chrome extension it so it's successfully signing sort order added but nothing is happening when I click it what if I just inverse this year like yeah okay so this sorting is actually working I just flipped the thingy the other way and everything worked so this now is can actually do this as a constant for fun sort by like Const is newer cool you know what we could actually just change this to be a ternary expression to be honest so that we get a can do this as a Const let me rewrite this so the sorter if this state dot sort order is added then the it's gonna be is newer that is the sorter otherwise it's going to be undefined I think that this looks cooler I can remove this right okay this this could actually be one light you're wasting really valuable video time on this now yeah I know but refactoring just feels really good stop it stop it now fine right so this is a bit confusing because we can't see which one we clicked so let's let's add some some styling to it so yes I also wanted to so at it that I can reverse the order so sort order no and let's also add some style style equals the font weights know if the mmmmmm it's that this dot state dot sort order equals no then this should be bold otherwise it should be normal normal normal that work now that is bold let me steal that copy paste it - this thing and then if the sort order is added then it should also be bold so now this works Wow I have created sauteing can ask a question why aren't the div tags inside of the UL tag artistic freedom this is valid HTML oh well it's it's actually not valid at all [Music] there we go ah hi it looks worse all right so we have this app it can do a bunch of things it can can do sorting that's actually the only thing that can do but use your imagination and think of this like we have this app in production it's it's out there it's used by users and stuff it's slide and we discover or we postulate we think that maybe that this time sorting is actually a better default right now natural sort or area is the default but we should probably make recently added the default maybe hmm let's try it we won't try that and the way your app is set up now the way we do it is to just go in the code here and say sort order added and now natural natural sorting is no longer the default it's it's time it's time sorting that is it's the default now and we push that we deploy it that is how you deploy an app without feature flags simple enough

Original Description

💖 Get started using feature flagging using LaunchDarkly http://launchdarkly.com 🔗 Support the show by becoming a Patreon https://www.patreon.com/funfunfunction 🔗 Code from the episode https://github.com/mpj/playlist-launchdarkly 🔗 mpj on Twitter https://twitter.com/mpjme 🔗 Help translate the show to your language http://www.youtube.com/timedtext_cs_panel?tab=2&c=UCO1cgjhGzsSYb1rsB4bFe4Q
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Fun Fun Function · Fun Fun Function · 0 of 60

← Previous Next →
1 Higher-order functions - Part 1 of Functional Programming in JavaScript
Higher-order functions - Part 1 of Functional Programming in JavaScript
Fun Fun Function
2 Map - Part 2 of Functional Programming in JavaScript
Map - Part 2 of Functional Programming in JavaScript
Fun Fun Function
3 Reduce basics - Part 3 of Functional Programming in JavaScript
Reduce basics - Part 3 of Functional Programming in JavaScript
Fun Fun Function
4 Destructuring: What, Why and How - Part 1 of ES6 JavaScript Features
Destructuring: What, Why and How - Part 1 of ES6 JavaScript Features
Fun Fun Function
5 Reduce Advanced - Part 4 of Functional Programming in JavaScript
Reduce Advanced - Part 4 of Functional Programming in JavaScript
Fun Fun Function
6 Closures - Part 5 of Functional Programming in JavaScript
Closures - Part 5 of Functional Programming in JavaScript
Fun Fun Function
7 Too many tools and frameworks!
Too many tools and frameworks!
Fun Fun Function
8 Currying - Part 6 of Functional Programming in JavaScript
Currying - Part 6 of Functional Programming in JavaScript
Fun Fun Function
9 Recursion - Part 7 of Functional Programming in JavaScript
Recursion - Part 7 of Functional Programming in JavaScript
Fun Fun Function
10 Promises - Part 8 of Functional Programming in JavaScript
Promises - Part 8 of Functional Programming in JavaScript
Fun Fun Function
11 Staying relevant as a programmer
Staying relevant as a programmer
Fun Fun Function
12 Factory Functions in JavaScript
Factory Functions in JavaScript
Fun Fun Function
13 Composition over Inheritance
Composition over Inheritance
Fun Fun Function
14 Software needs to be better - FunFunFunction #1
Software needs to be better - FunFunFunction #1
Fun Fun Function
15 Unit testing: How to get your team started - FunFunFunction #2
Unit testing: How to get your team started - FunFunFunction #2
Fun Fun Function
16 Straight-line code over functions - FunFunFunction #3
Straight-line code over functions - FunFunFunction #3
Fun Fun Function
17 Clojure - FunFunFunction #5
Clojure - FunFunFunction #5
Fun Fun Function
18 The growth stages of a programmer - FunFunFunction #6
The growth stages of a programmer - FunFunFunction #6
Fun Fun Function
19 5 tips to quickly understand a new code base - FunFunFunction #7
5 tips to quickly understand a new code base - FunFunFunction #7
Fun Fun Function
20 Semicolons cannot save you! - FunFunFunction #9
Semicolons cannot save you! - FunFunFunction #9
Fun Fun Function
21 Functors - FunFunFunction #10
Functors - FunFunFunction #10
Fun Fun Function
22 Functors: I was WRONG! - FunFunFunction #11
Functors: I was WRONG! - FunFunFunction #11
Fun Fun Function
23 Questions and Answers - FunFunFunction #12
Questions and Answers - FunFunFunction #12
Fun Fun Function
24 Streams - FunFunFunction #13
Streams - FunFunFunction #13
Fun Fun Function
25 Prototypes in JavaScript - FunFunFunction #16
Prototypes in JavaScript - FunFunFunction #16
Fun Fun Function
26 Fast or Flexible? - FunFunFunction #17
Fast or Flexible? - FunFunFunction #17
Fun Fun Function
27 Coders are herd animals - FunFunFunction #18
Coders are herd animals - FunFunFunction #18
Fun Fun Function
28 Weekend Kubernetes Shenanigans - FunFunFunction #19
Weekend Kubernetes Shenanigans - FunFunFunction #19
Fun Fun Function
29 Monad - FunFunFunction #21
Monad - FunFunFunction #21
Fun Fun Function
30 Moar Weekend Shenanigans - FunFunFunction #23
Moar Weekend Shenanigans - FunFunFunction #23
Fun Fun Function
31 Questions and Answers - FunFunFunction #24
Questions and Answers - FunFunFunction #24
Fun Fun Function
32 Losing motivation - FunFunFunction #25
Losing motivation - FunFunFunction #25
Fun Fun Function
33 LONGEST KUBERNETES SHENANIGANS! - FunFunFunction #26
LONGEST KUBERNETES SHENANIGANS! - FunFunFunction #26
Fun Fun Function
34 Fast code is NOT important - FunFunFunction #27
Fast code is NOT important - FunFunFunction #27
Fun Fun Function
35 Pair Programming a Facebook Messenger Bot - FunFunFunction #28
Pair Programming a Facebook Messenger Bot - FunFunFunction #28
Fun Fun Function
36 Writing unit tests for personal projects? - FunFunFunction #29
Writing unit tests for personal projects? - FunFunFunction #29
Fun Fun Function
37 Let's Code a Pomodoro Button - FunFunFunction #30
Let's Code a Pomodoro Button - FunFunFunction #30
Fun Fun Function
38 What editor do you use? - FunFunFunction #31
What editor do you use? - FunFunFunction #31
Fun Fun Function
39 Arrow functions in JavaScript - What, Why and How - FunFunFunction #32
Arrow functions in JavaScript - What, Why and How - FunFunFunction #32
Fun Fun Function
40 Is Programming Art? - MPJ's Musings - FunFunFunction #33
Is Programming Art? - MPJ's Musings - FunFunFunction #33
Fun Fun Function
41 Generators in JavaScript - What, Why and How - FunFunFunction #34
Generators in JavaScript - What, Why and How - FunFunFunction #34
Fun Fun Function
42 Haskell Basics - FunFunFunction #35
Haskell Basics - FunFunFunction #35
Fun Fun Function
43 Haskell - Baby's first functions - FunFunFunction #36
Haskell - Baby's first functions - FunFunFunction #36
Fun Fun Function
44 Is Big O relevant to you? - Q&A Part 1 - FunFunFunction #37
Is Big O relevant to you? - Q&A Part 1 - FunFunFunction #37
Fun Fun Function
45 How much are you allowed to Google? - Q&A Part 2 - FunFunFunction #38
How much are you allowed to Google? - Q&A Part 2 - FunFunFunction #38
Fun Fun Function
46 Haskell lists - FunFunFunction #39
Haskell lists - FunFunFunction #39
Fun Fun Function
47 var, let and const - What, why and how - ES6 JavaScript Features
var, let and const - What, why and how - ES6 JavaScript Features
Fun Fun Function
48 Why are some programming languages popular? - MPJ's Musings  - FunFunFunction #41
Why are some programming languages popular? - MPJ's Musings - FunFunFunction #41
Fun Fun Function
49 Does a developer need to be nice? - MPJ's Musings - FunFunFunction #42
Does a developer need to be nice? - MPJ's Musings - FunFunFunction #42
Fun Fun Function
50 bind and this - Object Creation in JavaScript P1 - FunFunFunction #43
bind and this - Object Creation in JavaScript P1 - FunFunFunction #43
Fun Fun Function
51 Examples of this and bind - Object Creation in JavaScript P2 -  FunFunFunction #44
Examples of this and bind - Object Creation in JavaScript P2 - FunFunFunction #44
Fun Fun Function
52 Prototype basics - Object Creation in JavaScript P3 - FunFunFunction #46
Prototype basics - Object Creation in JavaScript P3 - FunFunFunction #46
Fun Fun Function
53 Separation of concerns RANT - MPJ's Musings - FunFunFunction #47
Separation of concerns RANT - MPJ's Musings - FunFunFunction #47
Fun Fun Function
54 Cellular Automata - Pair Programming - FunFunFunction #49
Cellular Automata - Pair Programming - FunFunFunction #49
Fun Fun Function
55 The 'new' keyword - Object Creation in JavaScript P4 - FunFunFunction #50
The 'new' keyword - Object Creation in JavaScript P4 - FunFunFunction #50
Fun Fun Function
56 __proto__ vs prototype - Object Creation in JavaScript P5 - FunFunFunction #52
__proto__ vs prototype - Object Creation in JavaScript P5 - FunFunFunction #52
Fun Fun Function
57 Unity game pair programming - Let's code - FunFunFunction #53
Unity game pair programming - Let's code - FunFunFunction #53
Fun Fun Function
58 Throw out your tools - MPJ's Musings - FunFunFunction #54
Throw out your tools - MPJ's Musings - FunFunFunction #54
Fun Fun Function
59 Unit tests vs. Integration tests - MPJ's Musings - FunFunFunction #55
Unit tests vs. Integration tests - MPJ's Musings - FunFunFunction #55
Fun Fun Function
60 Object.create - Object Creation in JavaScript P6 - FunFunFunction #57
Object.create - Object Creation in JavaScript P6 - FunFunFunction #57
Fun Fun Function

Related Reads

Up next
Shopify Vs WooCommerce 2026 | Which One Is Better For Ecommerce?
Tutorial Stack
Watch →