@EffectTS_
Beginners Complete Getting Started course is out now ๐
From zero to building complete apps with effect
Type-safe, maintainable, testable apps, and it's just typescript ๐ฏ
Here is what you'll learn ๐๐งต
Typescript wizardy: `as const` + `satisfies`
Combine both to have type safety on Record keys and values + constant inferred types
You can then extract both keys and values as unions using `keyof` and `typeof` ๐ง
๐ก Flutter tip ๐ก
Use Isolate to avoid blocking the UI ๐
Example: loading a 5Mb txt file as a List takes 17 seconds โฑ๏ธ
Without Isolate the UI will freeze during this time ๐ฅถ
Wrap with to be safe again ๐ฆบ
With macros + primary constructors
@dart_lang
becomes insane ๐
Example: from a 50+ lines of code to just 1
Stay tuned, because this is going to be game-changing ๐คฏ
Most underrated react hook: useSyncExternalStore
Subscribe to external store changes and extract values in sync with react rendering
Ideal for things like event listeners ๐ฏ
Important frontend rule: data should be parsed and formatted before reaching the UI
Formatting inside a component is problematic
๐ Formatting is computed at every render
๐ Hard to maintain coherent formatting
Validate the data at request time
Unpopular opinion: a react component should contain few to no business logic ๐
A component is only responsible for
1๏ธโฃ Display content based on current state/context
2๏ธโฃ Send events
Everything else should be defined outside
Building production-ready typescript apps can be challenging ๐ซฃ
As your app becomes bigger, speed slows down, and your pain increases ๐ซ
@EffectTS_
is here to help, this is how ๐๐ฅ
Patterns are coming to
@dart_lang
๐ (Starting with Records)
Wait, what are Patterns?
Patterns bring dart to the next level ๐
Here is what we are talking about ๐๐งต
#dart
#flutter
Going ๐คฏ with local first and
@EffectTS_
โ๏ธ Api with the new `HttpApi`
โ๏ธ PGLite local database
โ๏ธ Drizzle for ORM queries
โ๏ธ Client with Remix
โ๏ธ Turborepo setup
All in 2 hours (no AI)! The ecosystem is awesome! ๐ช
New state management in
@FlutterDev
: signals โก๏ธ
I used signals to implement a complete Flutter app ๐ฒ
This is what I learned, and how I am using it ๐๐งต
How you write
@dart_lang
and
@FlutterDev
code will soon change forever ๐
2 new features are coming
๐ Static metaprogramming (macro)
๐ Primary constructors
Let me show you why it matters ๐๐งต
Dart 3 is nearly here, brining Patterns and Records with it ๐ฏ
This will radically change how you write
@dart_lang
(and
@FlutterDev
) apps
Learn all about them right now ๐งต๐
๐ก Dart tip ๐ก
Different methods to check the value of a variable ๐ ๏ธ
1๏ธโฃ Repeat == and || for each check
2๏ธโฃ Use a List and `contains`
๐ Use `case` since Dart 3 and patterns
Typescript-only pattern for full type-safety: constant list + record keys
๐ `as const` to extract values from list as type
๐ `Record` key using elements in the list
This *requires* you to add the key to the record if you add a new value to the list
What state management package should I use with
#flutter
? ๐ค
This week article will give you the answer ๐ก
๐ค riverpod
๐งฑ bloc
๐ฑ getx
๐ signals
Compare them all and decide ๐๐ผโโ๏ธ
Underrated state management strategy: Search Params
Push the state to the URL with `URLSearchParams`
๐ Less state management logic
๐ Works great with server components
๐ Navigation friendly (e.g. back button)
Use
@EffectTS_
with
@nextjs
to implement a Cookies service
โ Composable
โ Testable
โ Framework agnostic
And it's just a few lines of code ๐๐ผโโ๏ธ
This is how step by step ๐๐ฅ
๐ก Dart tip ๐ก
Patten matching to implement fromJson method ๐
You can use Map in patterns to convert from json
๐ Match the class properties and types, or throw a FormatException
Do not return Future in
#dart
, it's not safe โ ๏ธ
Wait what! What should I do instead?
There is an alternative, and it's easier and safer ๐๐ผโโ๏ธ
It's called Task, let's learn about it ๐๐งต
Do you use zod with typescript?
Then you must definitely check out
@EffectTS_
schema
๐ Decode and encode
๐ Equivalence
โ๏ธ Discriminated unions
๐ช Classes
๐ ๏ธ Compose
๐ Documentation
`satisifies`, `as const`, Record, what's the difference in typescript? ๐ง
Any typescript wizard must understand these ๐ง
This is how they all work (combined) ๐งช
๐ก Dart tip ๐ก
You can use operators in pattern matching ๐ช
or, and, ==, <, >, <=, >= and more ๐
You can also wrap the pattern in () to make it more readable ๐
๐ฅ Flutter tip ๐ฅ
Pattern matching is powerful ๐
You can match both `ConnectionState` and `` with `FutureBuilder`
Type-safe, secure, flexible and complete โ
@embersunn
Suggestion: you will probably learn more by picking a project that interests you and implementing it
As you face problems you look for solutions and learn new concepts
Focusing just on a long list of topics is not so effective with code
Do you want to make a
@FlutterDev
app in 2022? ๐ฑ+๐+๐ป
The ecosystem is awesome and keeps getting better ๐
Here is what packages you can use for your next app ๐๐งต
#flutter
#dart
End of the year
@EffectTS_
magic ๐ช
This is how I implemented an http request with error handling, validation, full type safety and composition ๐ฅ
Using only Effect ๐
Macro in
@dart_lang
3.4 (behind a flag ๐ฉ)
Work in progress to start experimenting with macros in dart 3.4 (possibly ๐ค)
Example: `fromJson` and `toJson` using `macro` and a method/constructor/class definition ๐
fpdart v1.0.0 is out now ๐
This is the biggest release of fpdart ever ๐
โ
#dart
3
โ New types
โ Improved performance
โ Simplified API
โ New getting started guide
Here is an overview of what's new ๐๐งต
First PGLite local-first example achieved โ๏ธ
@remix_run
+ PGLite +
@vite_js
with local database running and working
Experimentation in progress ๐
๐ก Flutter tip ๐ก
Since Dart 3 you can use pattern matching on `FutureBuilder` and `ConnectionState` ๐
Never forget to handle a state, no more if/else ๐ค
When macros (static metaprogramming) lands in Dart, everything Dart/Flutter will get to the next level ๐
Give me some time to review this example ๐
I'll get back with a full example in a thread soon ๐งต๐
Macros are live on the Flutter master channel (SDK ), that means you can do the following without any code generation, no freezed and no json_serializable! ๐๐คฏ
Thanks to millsteed for the example
New Extension Types in
@dart_lang
3.3 ๐ฅ
Make you code even more safe at compile time ๐งฑ
Example: Avoid issues with indexed access on `List` ๐
The best part? No runtime overhead, performance + safety at 0 cost ๐
What if your
#flutter
app fails? Should you throw? Error? Exception?
#dart
gives you both Error and Exception ๐ฏ
But how do they work? Which one should you choose? ๐ค
Here is the answer ๐๐งต
๐ก Dart tip ๐ก
Records allow to return multiple values ๐ฆ
You can avoid creating a class for simple values, simply use typedef + Records is less verbose ๐
@EffectTS_
course release date ๐
My Effect course is coming out on Wednesday, 14 August
10 modules, 55 lessons ๐ฏ
From zero to building complete apps with effect
Completely free, no email or anything required ๐
@nathanbaugh27
The idea that fiction provides less value than non-fiction is flawed
Fiction can teach you powerful lessons using the most powerful medium: Stories
Read fiction.
@EffectTS_
just won the award for the most exciting use of technology 2024 at
@thejsnation
#jsnation
๐
Thanks everyone for the support and the Effect team for the awesome work on the library ๐
Ever heard about signals for state management in
#flutter
? ๐ค
New entry in flutter, but looking really promising
1๏ธโฃ Define a signal using `signal`
2๏ธโฃ Access and update using `value`
3๏ธโฃ Wrap with `Watch` to rebuild
Yes, it is really this simple, and it just works ๐๐ผโโ๏ธ
I cannot believe how absurd is the combination of XState and
@EffectTS_
Seriously, the experience end-to-end is insane
โ Visual editor with
@statelyai
โ Actions using Effect
โ React components only layout and send events ๐
The revolution is coming ๐
Do you know
@dart_lang
? You should take a look at
@typescript
โ๏ธ
I have been working with both for years ๐ค
Here is a basic comparison of
#typescript
from a
#dart
perspective (and vice versa or course ๐๐ผโโ๏ธ) ๐๐งต
The ecosystem for web apps in 2024 is ๐ฏ
Just created a new project
โ
@nextjs
โ
@tailwindcss
(v4)
โ
@storybookjs
โ shadcn-ui
@shadcn
All working together, minimal config, full control ๐
Effect + XState + Local First are going to change how you write
#typescript
code.
If you are a web developer you must definitely be aware of these 3 new way of programming that are going to become the standard in Typescript in 2024.
@EffectTS_
is a library that exploits the
Do you know what an *abstract* class is in
#dart
? ๐ค
Why not a simple class? Why making it abstract? ๐ญ
The distinction is actually important and practical โ๏ธ
Let's see ๐๐งต
Adding
@DrizzleORM
to PGLite is one line ๐ช
However, now there is another beast to slain: database migrations in local-first
Wish me luck on exploring this ๐ซก
Dart 3 introduces Pattern Matching in
@dart_lang
๐
Patterns make your code more safe, and in dart they are super powerful ๐ฅ
Here are all the ways you can use patterns in dart (with real examples) ๐๐งต
๐ก Dart tip ๐ก
Destructuring Lists ๐๏ธ
โ Single elements
โ Skip elements with `_`
โ Destructure in lists with `...`
๐ Combine them all
โ ๏ธ The list must have the elements in that position
๐ก Dart tip ๐ก
Sum a list using Pattern matching ๐ฅ
๐ Match an empty list or a list with 1 element
๐ Use a Rest pattern (...) to call `sum` recursive
๐ฅ Flutter tip ๐ฅ
I like to define constants inside an abstract class (instead of global const variables ๐ โโ๏ธ)
With this I can simply use `Constants.` and group all constant under a common class name ๐ช
Flutter and dart are ๐ฅ
๐ `drift` sqlite database to store and stream state updates
๐ Pattern matching to handle loading and errors
๐งฌ fpdart type-safe and composable api
Type safe, fast, maintainable ๐
Separate UI from state ๐๐ผโโ๏ธ
The UI is only responsible for
1๏ธโฃ Render layout based on current state
2๏ธโฃ Send events
All the state management logic should be defined outside the component
Key for maintainable state management ๐
Flutter State Management in 2024 ๐ก
Riverpod, Bloc, Signals, GetX
How are they different? Which one should you use for you app? ๐ค
This is my experience with all of them ๐
Stop using server actions, there is a better way, it's called
@EffectTS_
rpc ๐
โ Type safe error handling
โ As simple as a function call
โ Full control on request and response
When you start using it it works like magic ๐ช
๐ฅ Flutter tip ๐ฅ
Use Records ๐๐ผโโ๏ธ
When a type does not need members or methods Records are ๐ช
โ Equality by value
โ Named
โ Less verbose
I am using them everywhere ๐
๐ก Dart tip ๐ก
๐ Callable objects
Allow an instance of your Dart class to be called like a function
Add a `call` method and you can execute it directly from the class instance ๐ช
๐ฅ Flutter tip ๐ฅ
How to extract elements with a type from a list?
You can use where + is ๐๐ผโโ๏ธ
But, did you know about whereType? ๐
Just specify the type and your are done ๐ช
โก๏ธ Flutter tip โก๏ธ
Private constructors allow to require a class to use a factory constructor ๐ ๏ธ
This is useful when you want to control internal values ๐
This is how it works ๐๐งต
๐กUpdate on XState + Effect๐ก
If you thought this combination was great, think again ๐ค
It's not just "great", it's mind blowing ๐
Add also
@statelyai
editor in the mix and ๐ช
Just like with
@EffectTS_
, once you experience this there is no coming back
๐ Dart tip ๐
Convert a callback API to Future ๐ก
Use `Completer` to create a Future from scratch
๐ Call `complete` when the execution is done
๐ Return `future`
Example: `Timer` from callback to Future ๐
XState Complete Getting Started Guide is out now ๐
Learn the power of actors and statecharts to manage the state of your app with XState
Here is what you'll learn ๐๐งต
type or interface in typescript? It depends, but! โ๏ธ
๐ Hovering on `type` you see all the properties
๐ Hovering on `interface` shows only the name
Keep this in mind when choosing one or the other
Supabase v1.0 for Flutter is nearly out ๐ฏ
Authentication with
@supabase
is just a few lines of code ๐ช
Learn how to go from 0 to a Complete Authentication system in minutes using
#flutter
and
#supabase
๐
riverpod + fpdart finally joining forces ๐ค
Part 4 of the fpdart + riverpod series is out now ๐
Learn how to use the riverpod generator with fpdart, connecting all together and displaying the UI ๐จ
The 'as' operator in
#dart
is evil ๐
'as' will break your app without you noticing
How?
Example: what is the result of this *valid* code ๐?
Let me tell you... ๐๐งต
๐ก State management with Riverpod ๐ก
๐ watch/read all necessary state
๐ Provide state/events to the UI
Also here the logic is all hidden inside each provider
Clear separation of concerns ๐
Error handling is crucial for any app โ
It can make or break your app (literally ๐๐ผโโ๏ธ)
#dart
offers many tools to save you from troubles ๐ฏ
Here they are ๐๐งต
XState is the perfect example of
@EffectTS_
on the frontend ๐ฅ
Manage all the logic of your app using the power of state machines and Effect
Future (present) of frontend state management ๐
XState unlocks writing real react components ๐ช
All the logic is defined inside the machine
The component is only responsible for
1๏ธโฃ Display the layout based on the current state
2๏ธโฃ Send events
Response type validation is also important.
Another step is adding `effect/schema` or `zod` to validate the shape of the response
Complete type-safety, avoid a lot of headaches
How I use React query:
1. Create custom hooks that wrap related useQuery and useMutation calls.
2. Inline queryFn and mutationFn args. This enforces always using React query to query and mutate.
3. Colocate related queries and mutations in the same file, and invalidateQueries
Don't be scared,
@EffectTS_
is just typescript ๐๐ผโโ๏ธ
That's what makes it great ๐ฅ
It's easy to convert values and functions to Effect, sync, async, error handling, and more ๐๐ฅ
@housecor
To make this even easier you can use eslint-plugin-deprecation
It reports as error every function marked with deprecated
Easy to avoid legacy code ๐๐ผโโ๏ธ
Live queries with PGLite +
@DrizzleORM
๐ง
Combine drizzle query builder, compile it to sql, and pass it to PGLite live query
Sync changes with local db at lighting-speed โก๏ธ
Did you know you can create games with Typescript? ๐
I used
@excaliburjs
with
@EffectTS_
to setup a game scene, all Typescript ๐ฅ
Add XState
@statelyai
as well for next level results ๐
And it's all just Typescript โจ
@EffectTS_
with React 19 is out right now ๐
I packed everything that I learned using Effect on React 19 production codebases in one complete project template
All for free ๐๐
Typescript generics in React components ๐ง
Did you know generic types can be used also in react?
You can make sure the `name` of your form inputs conform to the shape of your schema
Brings better type safety also on the frontend ๐