Questions tagged [global-state]

66 questions
104
votes
9 answers

Laravel: Where to store global arrays data and constants?

I just started working with Laravel. I need to rewrite a whole system I made some years ago, using Laravel 4 as base framework. In my old system, I used to have a constant.php file with some constants declared, and a globals.php file which contained…
Marco Madueño Mejía
  • 1,105
  • 2
  • 9
  • 7
29
votes
6 answers

Is Perl's flip-flop operator bugged? It has global state, how can I reset it?

I'm dismayed. OK, so this was probably the most fun Perl bug I've ever found. Even today I'm learning new stuff about Perl. Essentially, the flip-flop operator .. which returns false until the left-hand-side returns true, and then true until the…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
26
votes
2 answers

Managing user's global state on next.js application

I am coming from the world of SPA's and REST/GraphQl API's. Now I am building personal project with Next.js library for SSR(Server Side Rendered) React App. Since I used Redux in all of my single page Apps, I'm now wondering how should I manage user…
11
votes
1 answer

Guidance on how to make a theming mechanism that effects all components in Angular?

Question: I need guidance on how to write a mechanism in Angular to set the "Look and Feel" of components globally in my application. Please note, I'm trying to learn @ngrx/platform and I thought this would be an interesting design constraint;…
Armeen Moon
  • 18,061
  • 35
  • 120
  • 233
10
votes
4 answers

How can I avoid global state?

So, I was reading the Google testing blog, and it says that global state is bad and makes it hard to write tests. I believe it--my code is difficult to test right now. So how do I avoid global state? The biggest things I use global state (as I…
Jim
  • 11,229
  • 20
  • 79
  • 114
10
votes
4 answers

What is the purpose of the extra result parameter of atomicModifyIORef?

The signature of modifyIORef is straightforward enough: modifyIORef :: IORef a -> (a -> a) -> IO () Unfortunately, this is not thread safe. There is an alternative that adresses this issue: atomicModifyIORef :: IORef a -> (a -> (a,b)) -> IO b What…
leftaroundabout
  • 117,950
  • 5
  • 174
  • 319
6
votes
2 answers

Does python's `unittest.mock.patch` mutate global state?

I'm trying to determine if Python's mock.patch (unittest.mock.patch in Py3) context manager mutates global state, i.e., if it is thread-safe. For instance: let's imagine one thread patches function bar within function foo with a context manager, and…
Andrew Gorcester
  • 19,595
  • 7
  • 57
  • 73
5
votes
4 answers

Can pure functions read global state?

Please note: by a "pure" function, I don't mean "pure virtual" I'm referring to this If a function "reads" some global state, does that automatically render it impure? or does it depend on other factors? If it automatically renders it impure, please…
hasen
  • 161,647
  • 65
  • 194
  • 231
4
votes
0 answers

Zustand: One State Split Into Slices or Multiple Stores?

I'm using Zustand for state management. Currently, I have 20 slices. And I'm afraid the number of slices will triple. What would be the best approach, splitting one really large state into slices or creating multiple stores (and splitting each one…
3
votes
2 answers

Rust, locking a mutex when droping a Variable causes Deadlock

I hope this isnt too much of a tangent however I think it is neccesary to understand the problem: I am currently writing a JIT in rust that traces operations, compiles them to spirv and executes the computations on the GPU (heavily inspired by…
3
votes
1 answer

Handling large nested objects with writable stores, performance concerns

I have a writable store export default writable({}) My server is constantly pushing updates to this store and those handlers are in a js file const handlers = { newUser: async (user) => { userStore.update(user => { …
LAZ
  • 402
  • 4
  • 15
3
votes
1 answer

Why are not this implementation considered compatible with their interface by PHP?

I have these two interfaces: interface Observer { public function notify(Observable $observable, ...$args); } interface Observable { public static function register(Observer $observer); public function notifyObservers(); } And here is…
CarlosCarucce
  • 3,420
  • 1
  • 28
  • 51
3
votes
4 answers

How to avoid global state in React applications?

In my React app, I need to store some data which needs to be accessible pretty much everywhere, but don't want to keep it in a global (i.e., static) data structure so that it's easy to mock for my unit tests and the style guide. The data I mean is…
mik01aj
  • 11,928
  • 15
  • 76
  • 119
2
votes
1 answer

What is the difference between uptime and uptime_since_flush_status?

I have been reading on mysql global status variables and I see two values: uptime uptime_since_flush_status What does uptime_since_flush_status mean?
Uday
  • 1,480
  • 4
  • 27
  • 44
2
votes
2 answers

React with Recoil, large array is lagging because of many re-renders

I have an array of objects, around 400 items. The component tree looks something like this App -> Page (useRecoilState(ListAtom) for consumption) -> List -> Item (useSetRecoilState(ListAtom) for mutation) -> Information …
PGT
  • 1,468
  • 20
  • 34
1
2 3 4 5