Patrick G's Avatar

Patrick G

@relevantelement

Web Dev, Data, Marketing

96
Followers
947
Following
21
Posts
31.10.2024
Joined
Posts Following

Latest posts by Patrick G @relevantelement

I didn't mean to mislead anyone. I made it for myself and didn't publish or share it anywhere besides GitHub. Sorry if I upset you.

08.03.2026 00:35 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Sorry about that!

08.03.2026 00:33 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Preview
The 16-Line Pattern That Eliminates Dependency Passing, & Understanding How Effect Systems Work Learn how a tiny runtime using JavaScript generators can transform how you structure...

See article for more: dev.to/doeixd/the-1...

21.07.2025 14:52 πŸ‘ 1 πŸ” 1 πŸ’¬ 0 πŸ“Œ 0
Preview
The 16-Line Pattern That Eliminates Dependency Passing, & Understanding How Effect Systems Work Learn how a tiny runtime using JavaScript generators can transform how you structure...

See article for more: dev.to/doeixd/the-1...

21.07.2025 14:52 πŸ‘ 1 πŸ” 1 πŸ’¬ 0 πŸ“Œ 0

This is the same pattern used by:
- Redux-Saga for side effects
- Effect for ctx / effects
- Koa for middleware

Benefits:
βœ“ No dependency passing through layers
βœ“ Test with simple mock objects
βœ“ Add new dependencies without touching existing functions
βœ“ See dependencies at point of use

21.07.2025 14:52 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image

Complete working example:

21.07.2025 14:52 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image

The runtime that makes this work:

21.07.2025 14:52 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
// Define what can be requested
const getDB = () => (context) => context.db;
const getLogger = () => (context) => context.logger;
const getEmailer = () => (context) => context.emailer;

// Pull only what you need
async function* notifyUser(user) {
  const emailer = yield getEmailer();  // Pull emailer when needed
  return emailer.send(user.email);
}

// Define what can be requested const getDB = () => (context) => context.db; const getLogger = () => (context) => context.logger; const getEmailer = () => (context) => context.emailer; // Pull only what you need async function* notifyUser(user) { const emailer = yield getEmailer(); // Pull emailer when needed return emailer.send(user.email); }

JavaScript generators let us flip this: instead of passing dependencies down, functions pull what they need:

21.07.2025 14:52 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
async function handleRequest(req, res, db, logger, emailer) {
  // Only uses logger, but must accept all deps to pass down
  logger.info('Request received');
  return processUser(req.userId, db, logger, emailer);
}

async function processUser(userId, db, logger, emailer) {
  // Still doesn't use emailer
  const user = await db.getUser(userId);
  return notifyUser(user, db, logger, emailer);
}

async function notifyUser(user, db, logger, emailer) {
  // Finally uses emailer!
  return emailer.send(user.email);
}

async function handleRequest(req, res, db, logger, emailer) { // Only uses logger, but must accept all deps to pass down logger.info('Request received'); return processUser(req.userId, db, logger, emailer); } async function processUser(userId, db, logger, emailer) { // Still doesn't use emailer const user = await db.getUser(userId); return notifyUser(user, db, logger, emailer); } async function notifyUser(user, db, logger, emailer) { // Finally uses emailer! return emailer.send(user.email); }

The problem: dependency passing through function chains

21.07.2025 14:52 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Every JavaScript developer has written this function:

processOrder(orderId, userId, db, logger, cache, validator, emailer, metrics)

Where half the parameters are just passed to other functions.

Here's how to fix this with a pattern using generators - in just 16 lines.

21.07.2025 14:52 πŸ‘ 2 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Preview
The JavaScript Library for the DOM You Don't Control Your JavaScript breaks every Tuesday. Not because you wrote bad code, but because the...

Another JavaScript framework!? dev.to/doeixd/the-j...

12.07.2025 11:15 πŸ‘ 2 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Preview
The Well-Grounded Data Analyst Complete eight data science projects that lock in important real world skills–along with a practical process you can use to learn any new technique quickly and efficiently.</b> The Well-Grounded Data...

My book "The Well-Grounded Data Analyst" is out early 2025!

It is a collection of real-world data analysis projects to level up your skills and you can already get it in early access.

Use the code au35asb to get 35% off (on any Manning title, not just mine!)

www.manning.com/books/the-we...

27.11.2024 07:52 πŸ‘ 9 πŸ” 1 πŸ’¬ 0 πŸ“Œ 2
Post image

🌟 The the first official release of the UCM Desktop app is here!

Browse your local codebase, click through to source definitions, and read the docs, all in a sleek new UI. ✨

github.com/unisonweb/uc...

09.01.2025 19:54 πŸ‘ 22 πŸ” 11 πŸ’¬ 0 πŸ“Œ 3
Preview
The Most Elegant Configuration Language Dmitrii Kovanikov's Personas Web Space

I finished creating The Most Elegant Configuration Language.

It’s done.

I can rest now.

My mission is accomplished.

chshersh.com/blog/2025-01...

06.01.2025 09:56 πŸ‘ 60 πŸ” 10 πŸ’¬ 8 πŸ“Œ 1

years ago when i moved from react to solid it took me 1-2 months to undo react brain

i did some react yesterday for an example wow i had such a hard time with the fact that functions run more than once

crazy how your brain flips around

13.12.2024 00:56 πŸ‘ 60 πŸ” 1 πŸ’¬ 5 πŸ“Œ 0

Exciting!

11.12.2024 22:53 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

What sort of code/commands? Could you give an example of what you're looking for?

05.12.2024 21:21 πŸ‘ 3 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Preview
A preview of Ezno's checker Try it out today, what it does and more!

I'm watching the talk and saw that you're planning on using TypeScript types to aid in performance, that reminds me of kaleidawave.github.io/posts/a-prev... which you might find interesting.

04.12.2024 01:27 πŸ‘ 5 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Is node.js compatibility on the distant future roadmap? If so, will it have to be done from scratch, or do you think it'll be possible to steal most of the code?

04.12.2024 01:17 πŸ‘ 3 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Also, is it possible to make syscalls or have embedded C with porfor?

04.12.2024 01:12 πŸ‘ 3 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

It's still possible to use eval, you'd just have to bundle the entire compiler, right?

04.12.2024 01:12 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

πŸ¦‹

01.12.2024 04:11 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Post image

πŸŽ„You and your friends are cordially invited to Unison's #AdventOfCode season.

Spread the word: www.unison-lang.org/adventofcode...

27.11.2024 14:01 πŸ‘ 15 πŸ” 6 πŸ’¬ 0 πŸ“Œ 3
Post image

I don't think enough people know scoped styles are built into the browser now...

22.11.2024 13:41 πŸ‘ 6 πŸ” 0 πŸ’¬ 0 πŸ“Œ 1

Hello Bluesky πŸ‘‹ Is there anyone out there?

16.11.2024 22:17 πŸ‘ 3 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

Or Rescript

15.11.2024 22:11 πŸ‘ 3 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

On my list: Swift, Odin, or Roc

15.11.2024 22:11 πŸ‘ 2 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Octane: A Query Builder for OCaml
Octane: A Query Builder for OCaml YouTube video by TJ DeVries

I admire how good TJ is at explaining technical concepts. Even if you have 0 interest in OCaml this has some great stuff about SQL in general and metaprogramming/macros

youtu.be/JFZvnGD_hV8

09.11.2024 13:46 πŸ‘ 53 πŸ” 6 πŸ’¬ 4 πŸ“Œ 1