正在加载视频...

视频加载失败

I made a state management library for React. It's called simple store. Goal: make Zustand way simpler ⭐ - Stores are like atom() in Jotai, so types are inferred - You can select nested values, and use *them* as stores too To understand that last point, watch to the...

79,936 次观看 • 11 个月前 •via X (Twitter)

35 条评论

Ben Holmes 的头像
Ben Holmes11 个月前

I have a full breakdown on YouTube!

Ben Holmes 的头像
Ben Holmes11 个月前

The source:

Kevin Marques 的头像
Kevin Marques11 个月前

We don't need "simple" state manager. They already are simple, because it's just a reducer. Wtf is this trend from some developers to always search for "simple" solutions, when the world need expertise, robust and strong software ?

qwertea 的头像
qwertea11 个月前

Really nice, would be great if getting deeply nested values didn’t require a chain of selects though but rather a way to use one select with an object or comma separated strings maybe

Ben Holmes 的头像
Ben Holmes11 个月前

We're tracking an issue for this right now! If we support this, I believe we'll use Zustand's arrow function syntax as an alternative. Ex. select(store => store.deeply.nested.value)

Name cannot be blank 的头像
Name cannot be blank11 个月前

Or use Solid with signals.

zenith 的头像
zenith11 个月前

I really love your approach on this. thanks for building and sharing.

promethean 的头像
promethean11 个月前

If I may, subscribe returning a tuple of current value and unsubscribe might save people a bit of effort

json™️ 的头像
json™️11 个月前

thank you for the tutorial @code_cowboy cc @kevfaveri

Sp Loff 的头像
Sp Loff11 个月前

But why? Aren't there already a tons of state management solutions?

Paul van Dyk 的头像
Paul van Dyk11 个月前

What happens if you have side effects, e.g., `meta: { contentLength: number }` which is the length of the `content` store value? Is there any way to handle those types of effects?

Ben Holmes 的头像
Ben Holmes11 个月前

That sounds like derived values. I'd suggest generating those in your component instead of putting on the store directly. You can also hack it using subscribe: =>

Tony OHagan 的头像
Tony OHagan11 个月前

Just walk over to Vue and use Pinia stores and all this subscribe complexity disappears. MVVM is so much simpler with right reactivity model.

Muhammad Mejanul Haque 的头像
Muhammad Mejanul Haque11 个月前

I honestly don't get why people use zustand instead of jotai. some people just blindly follows other devs. you are using a library to write less code, not to write the same amounts of code. this is not a redux era.

Pavitra Golchha 的头像
Pavitra Golchha11 个月前

this is nanostores

Kerem Atam 的头像
Kerem Atam11 个月前

I like this work but if the selling point of this is being simple, then I think the only thing that really needs fixing in Zustand is type inference. Anything beyond that doesnt add simplicity, it just forces new patterns onto devs (which is fine, but i would nto call it "simple" anymore).

Eduardo Alvarez 的头像
Eduardo Alvarez11 个月前

Does it have a website? That’s how I judge state management tools. Redux review is… designed with Bootstrap 4. Zustand, that one is good!

Niall O'Brien 的头像
Niall O'Brien11 个月前

Looks neat, does it also support hydration for SSR much like Jotai?

Verious B. Smith III 的头像
Verious B. Smith III11 个月前

That's nice

Kirill Rodionov 的头像
Kirill Rodionov11 个月前

Valtio solved this… go check it out it’s goated

Stephen Burke 的头像
Stephen Burke11 个月前

Nicely done sir 🫡

Tom Firth 的头像
Tom Firth11 个月前

This looks great. > You can select nested values, and use *them* as stores too Sounds hot, how does that compare to jotai + optics? That said, we all know that Daishi has a monopoly on state management these days. He may come for you.

Seb ⚛️ ThisWeekInReact.com 的头像
Seb ⚛️ ThisWeekInReact.com11 个月前

I like this kind of abstraction Just wondering if it's not possible to build it on top of Zustand? I remember some lens/optics plugins/middleware in the past

Carlos Rico-Ospina 的头像
Carlos Rico-Ospina11 个月前

I just hash and put the entire client state in the URL params. What’s the issue

Michael Magán 的头像
Michael Magán11 个月前

congrats on the launch

Asdrúbal Chirinos (Astro) 🚀 的头像
Asdrúbal Chirinos (Astro) 🚀11 个月前

You've got my attention.

David K 🎹 的头像
David K 🎹11 个月前

This is basically the latest XState Store (Zustand + Jotai)

Webiny Enterprise CMS+ ⚡️ 的头像
Webiny Enterprise CMS+ ⚡️11 个月前

Cool concept! Love the simplicity angle.

Sandrin Joy 的头像
Sandrin Joy11 个月前

😍

Matthew Volonnino 的头像
Matthew Volonnino11 个月前

Also something I think would be great DX that Zustand has, is updating parts of the store without needing to spread the store and would only update that specific part of store (keeping re renders optimized): const store = { foo: “bar”, bar: “baz” } store.set({bar: “z”})

Karan Jagtiani 的头像
Karan Jagtiani11 个月前

Does your simple store support middleware like persistence or logging out of the box?

Omar Shoura 的头像
Omar Shoura11 个月前

This is really neat. Feels pretty simple

Leszek 的头像
Leszek11 个月前

How many levels deep we are on abstractions ?

Jacob Kelley 的头像
Jacob Kelley11 个月前

This is dope!

Robert 🟠 的头像
Robert 🟠11 个月前

what happened to lazyvim?🤣

相关视频

Did you know if you tried to open a Trader Joe's, Grocery Outlet, or soon even a Mollie Stone's in San Francisco - you can't? That's because SF has a rule that formula retail chain stores that have more than 11 stores (worldwide!) can not open in commercial districts without a conditional use permit. With grocery stores and pharmacies closing across our city, these permits can delay opening new stores by 6-9 months - delaying much needed affordable food in our neighborhoods. So today I announced legislation to fix it. Going forward, any parcel already designated as a formula retail chain can convert to a grocery store or pharmacy without an additional conditional use permit. This will save them months on opening. For any new grocery store that opens, we will also allow them to include a bank, pharmacy, or restaurant without the need for another conditional use permit. As grocery stores consolidate and get smaller, this will help them occupy larger spaces while also bring more needed services to neighborhoods in need. And lastly, we will add grocery stores and pharmacies to the city's priority processing list. Importantly, this legislation isn't going to change the character of your neighborhood. It only regulates parcels that are already designated for formula retail chains. Because amidst an affordability crisis restricting access to food and medicine, we need to make it easier to open needed services. Not bury them in red tape. Thank you Supervisors Sherrill and Melgar for your early cosponsorship of our legislation. We will introduce it at the Board of Supervisors in the weeks ahead, and expect it to pass before the end of the year.

Bilal Mahmood 馬百樂

54,921 次观看 • 1 个月前

Today I announced the Affordable Groceries Act to address our growing affordability crisis in San Francisco. For years, the price of milk, fresh vegetables, and more has been rising by double digits. At the same time, large chain corporations are leaving grocery stores and pharmacies as "zombie stores" - paying their lease to keep the storefronts vacant and block competition. The Affordable Groceries Act aims to end those food deserts by providing stimulus incentives to new grocery stores and pharmacies, while taxing zombie stores to generate revenue that could be used to fund new stores that sell affordable, fresh food. It works in 3 steps: 1. Streamline new stores, by eliminating conditional use permits for new groceries and pharmacies on vacant lots, while providing tax credits to reduce pharmacy gross receipts taxes. 2. Tax zombie stores, by ensuring that large chain corporations that deliberately leave grocery stores and pharmacies empty pay a vacancy tax for as long as they block competition from using the storefronts. The tax would not apply to small businesses, or to any new store that opens after January 2027. 3. Fund affordable groceries, by establishing an Affordable Grocery Fund that will subsidize operators that provide fresh affordable food. This could help corners stores convert into full grocery stores with fresh food, or let the city purchase buildings and rent them out to grocery operators who agree to keep prices low. We're bringing Affordable Groceries Act to the ballot this November, so you can make your voices heard that every San Franciscan deserves fresh affordable food in their neighborhood.

Bilal Mahmood 馬百樂

13,695 次观看 • 4 个月前

Friedberg Predicts NYC’s Socialist Grocery Stores Will Be Wildly Popular and a DSA Marketing Tool for 2028 david friedberg: “I think that people have it wrong. I think these grocery stores are going to be wildly popular. I think that everyone's being a little bit too long-sighted in their view on what's going to happen with these grocery stores, with the basic obvious economic arithmetic that someone has to pay for this, and who's going to pay for it, and blah, blah, blah. I don't think it really matters because over the near term, what the cheap grocery stores do is create an incredible success story for socialism that will help to support and fuel the socialist wave in urban centers around this country. Think about the social network effect of the grocery store. So there's a couple of them, and then people start traveling from far away to the cheap grocery store because it has this discount. Again, this'll play out over the next 24 months, going into the 2028 election cycle, and everyone's like, ‘This is so wildly popular. People are coming in from all over the place to go to these grocery stores.’ They're not checking IDs, because IDs are racist, and you can't check IDs to vote, so we shouldn't be able to check IDs for grocery stores. So people will come in from all over the place to use these grocery stores. The demand will go up. And then they'll start to open more and more grocery stores like this. And let's say each one loses $10 million/year and they get to 10 or 20 of these. That's $200 million of losses/year on the grocery store chain. But it creates this extraordinary social movement for more of these grocery stores supporting the DSA and so on. $200 million/year on a $125 billion/year budget for the city of New York is nothing. It's less than a quarter of a percent of the city's budget. That is so cheap to market the DSA platform, and to get the DSA platform to become a social marketing element that drives the next wave here. So again, I do think that these grocery stores, believe it or not, they sound silly, they sound small, but I predict that they will be deemed a point of success, and they will end up being a big part of the fuel for the DSA going into 2028.”

The All-In Podcast

128,150 次观看 • 3 个月前