Questions tagged [state]

The contents of memory locations, at any given point in the program's execution, is called the program's state.

The contents of memory locations, at any given point in the program's execution, is called the program's state.

More information is available on Wikipedia.

9107 questions
35
votes
2 answers

Combine state with IO actions

Suppose I have a state monad such as: data Registers = Reg {...} data ST = ST {registers :: Registers, memory :: Array Int Int} newtype Op a = Op {runOp :: ST -> (ST, a)} instance Monad Op where return a = Op $ \st -> (st,…
emi
  • 5,380
  • 1
  • 27
  • 45
34
votes
6 answers

React component not updating when store state has changed

Below is my component class. The component never seems to execute componentWillUpdate(), even when I can see the state updating by logging before the return in mapStateToProps. The state is 100% changing, however the component doesn't…
Jacob Mason
  • 1,355
  • 5
  • 14
  • 28
33
votes
6 answers

In javascript, how can I uniquely identify one browser window from another which are under the same cookiedbased sessionId

The users of my web application may have more than one browser window open and pointed to the same page. I would like the state of certain things in the page (loaded via ajax) to be retained across postbacks. I can either store in a cookie or on…
srmark
  • 7,942
  • 13
  • 63
  • 74
33
votes
4 answers

Should you use "extends" or "with" keyword for ChangeNotifier? - Flutter

I have seen several examples of a model extending ChangeNotifier using both 'extends' and 'with' keywords. I am not sure what the difference is. class myModel extends ChangeNotifier {...} class myModel with ChangeNotifier {...} What is the…
Gary AP
  • 747
  • 5
  • 11
33
votes
3 answers

ReactJS How do you switch between pages in React?

So coming from an Angular/AngularJS background, you have states, and each state is a separate page. E.g. in a social network you can have a state with your feed, a state with a list of your friends, or a state to see a profile etc. Pretty…
Alexander Donets
  • 617
  • 1
  • 5
  • 13
33
votes
8 answers

Incrementing state value by one using React

In React I am trying to make a button increment a value stored in state. However using the code below function my value is set undefined or NaN when using handleClick. class QuestionList extends React.Component { constructor(props) { …
dwigt
  • 611
  • 1
  • 8
  • 18
33
votes
1 answer

I do not understand the concept of Non Deterministic Turing Machine

I do not the understand the concept of Non Deterministic Turing Machine. I guess I understand the term Non deterministic algorithm : (nondeterministic algorithm is an algorithm that can exhibit different behaviors on different runs, as opposed to a…
Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
32
votes
2 answers

Android - Best Practices for ViewModel State in MVVM?

I am working on an Android App using the MVVM pattern along LiveData (possibly Transformations) and DataBinding between View and ViewModel. Since the app is "growing", now ViewModels contain lots of data, and most of the latter are kept as LiveData…
Memordei
  • 451
  • 1
  • 5
  • 6
31
votes
3 answers

How are mutable arrays implemented in Haskell?

I've read many research papers on this topic, and they usually argue that arrays are implemented using Monads. But none of these papers gave a clear definition of how the "type" Array itself should be defined, they only gave definitions for the…
is7s
  • 3,500
  • 1
  • 20
  • 41
31
votes
3 answers

Can a `ST`-like monad be executed purely (without the `ST` library)?

This post is literate Haskell. Just put in a file like "pad.lhs" and ghci will be able to run it. > {-# LANGUAGE GADTs, Rank2Types #-} > import Control.Monad > import Control.Monad.ST > import Data.STRef Okay, so I was able to figure how to…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
30
votes
3 answers

How to maintain the state of widget in ListView?

I have a list of clickable widgets[i.e MarkWidget] when the widget is clicked the state of widget is changed. But when the list is scrolled to the bottom and scrolled back to the top all widget's state is reset to default. How do I stop/force…
Ajay Kumar
  • 15,250
  • 14
  • 54
  • 53
30
votes
9 answers

Fragment replacement triggers onQueryTextChange on searchview

This is how I navigate through my app: Open fragment with list Filter list by a text entered in searchview Tap on listitem (list fragment gets replaced by detail fragment) Navigate back (detail fragment gets replaced by list fragment) When I…
Tom
  • 489
  • 4
  • 10
30
votes
4 answers

Should an Angular service have state?

Recently some co-workers and I were having a discussion as to whether or not AngularJS services should have state or not. We came up with some arguments for and against it and I wanted to get additional thoughts and feedback on the subject. In my…
testing123
  • 11,367
  • 10
  • 47
  • 61
29
votes
3 answers

How to make angular ui-router's parent state always execute controller code when state changes?

Let's say we have a parent-child relationship defined in our $stateProvider as follows: .state('myProfile', { url: "/my/profile", templateUrl: 'my/profile.html', controller: 'MyProfileController' …
egervari
  • 22,372
  • 32
  • 121
  • 175
28
votes
7 answers

Flutter GlobalKey current state is null

What I'm basically trying to do (And I did, details up ahead) is create a screen with several forms the content of which is changed using a button (NEXT). So I have 3 forms, when I press next, I save the first form and pass to the other, what I did…
Amine
  • 1,396
  • 4
  • 15
  • 32