state

Flutter: Does it matter what code is in setState()?

爷,独闯天下 提交于 2019-12-05 01:17:25
When we want a StatefulWidget to rebuild we call setState() but does it really matter if the code we type is inside that function or outside of it? Is this: class _ShoppingListState extends State<ShoppingList> { Set<Product> _shoppingCart = new Set<Product>(); void _handleCartChanged(Product product, bool inCart) { setState(() { if (inCart) _shoppingCart.add(product); else _shoppingCart.remove(product); }); } } the same as this: class _ShoppingListState extends State<ShoppingList> { Set<Product> _shoppingCart = new Set<Product>(); void _handleCartChanged(Product product, bool inCart) { if

how to simulate haskell state?

会有一股神秘感。 提交于 2019-12-05 00:49:32
问题 I wrote some haskell code to toggle a pin on the raspberry pi depending on an interrupt I get from another pin on the raspberry pi. I simply do not know how to toggle the state of the pin without knowing the previous toggle state. The program itself is very simple. import Control.Concurrent import Data.IORef import HasberryPi main = do wiringPiSetup pinMode 0 output pinMode 7 input pullUpDnControl 7 pull_down wiringPiISR 7 edge_both onoff threadDelay (15*(10^6)) onoff s = do a <- readIORef s

Upgrade from .NET 3.0 to 3.5: Sites set to StateServer revert to InProc when in Web Garden

纵饮孤独 提交于 2019-12-04 23:45:26
问题 Scenario: Take a server running .NET 3.0 and an ASP.NET Web site running in an application pool that has Web gardens enabled (number of processes: 3). The web.config configuration is as follows: <sessionState cookieless="UseCookies" cookieName=".authz" mode="StateServer" regenerateExpiredSessionId="true" stateConnectionString="tcpip=127.0.0.1:42424" timeout="60" useHostingIdentity="true" /> Now upgrade the machine to .NET 3.5 SP1. Reboot the server. Result: sessions are no longer maintained

GridView is scrolling back to top after row selection

左心房为你撑大大i 提交于 2019-12-04 23:24:53
I've got one long GridView control on ma website. It allows row selection. The problem is, when I scroll down this GridView and select some of the bottom rows the selection occurs, but whole GridView is scrolling back to top. Does enyone know how to avoid this? If it's happening during a postback, then in your <%@ Page %> directive you can add the following: MaintainScrollPositionOnPostback="true" This was added in .NET 2.0, and adds some JavaScript to the page to ensure that the page scrolls back down to the control that caused the postback. Works a treat. I've found another solution. If you

how is state of instance variables of a stateless bean preserved for next invocation in EJB?

对着背影说爱祢 提交于 2019-12-04 22:16:31
问题 I am reading Java EE7 documentation and here is what it says for stateless bean. I am confused with what is meant by the statement marked in bold below A stateless session bean does not maintain a conversational state with the client. When a client invokes the methods of a stateless bean, the bean's instance variables may contain a state specific to that client but only for the duration of the invocation. When the method is finished, the client-specific state should not be retained. Clients

【讲古堂】状态机(二)

那年仲夏 提交于 2019-12-04 22:05:41
状态机 状态机的概念是来自硬件的。描述一系列状态转换的电路叫状态机。主要用来实现一个数字系统设计中的控制部分。运行模式类似于CPU,但和CPU相比,具有结构简单、易读易懂等特点。 对于无限个状态(无限状态机,Infinite State Machine,ISM)是难以检证的,所以这里所说的状态机通常是指有限状态机或有穷状态机,即Finite State Machine,FSM。 状态模式可以允许客户端改变状态的转换行为,而状态机则是能够自动改变状态,状态机是一个比较独立的而且复杂的机制。 状态机看上去就像是一个有向图,其中状态是图的节点,而状态转换则是图的边。 此外这些状态中还必须有一个初始状态和至少一个接受状态。 但是由于一些原因并不会执行初始化(initialization),而是直接通过一个节点进入状态是允许的,则此节点称之为进入节点(Entry Point)。 进入终了状态的节点称为退出节点(Exit Point) 转移(Transitions)是两个状态之间的一种关系,表示对象将在源状态(Source State)中,因为预先定义的触发器的发生导致警界条件满足时进入目标状态(Target State)。 触发器(Trigger):是转移的诱因,可以是一个信号,事件、条件变化(a change in some condition)和时间表达式。 警界条件(Guard

【讲古堂】状态机(一)

浪尽此生 提交于 2019-12-04 22:05:24
状态(State) 状态,指在对象的生命周期中的某个条件下的状况,在此期间对象将满足某些条件、执行某些活动活活等待某些事件。 所有对象都有状态,状态是对象执行了一系列活动的结果,当某个事件发生后,对象的状态将发生变化。 在不同状态下,同一对象表现出的行为也是不同的。 一个对象的行为取决于一个或多个动态变化的属性,这样的属性叫做状态,这样的对象叫做有状态的对象,这样的对象状态是从事先定义好的一系列值中取出的。 当一个这样的对象与外部事件产生互动时,其内部状态就会改变,从而使得系统的行为也随之发生变化。 行为(Action) 行为指的就是对象的功能,大多行为是有对应的方法或者处理的。 行为的平行性和平等性 平行性指的是各个状态下的行为所处的层次是一样的,相互独立的、没有关联的,是根据不同的状态来决定到底走平行线的哪一条。 行为是不同的,当然对应的实现也是不同的,相互之间是不可替换的。 平等性强调的是可替换性,分别是同一行为的不同描述或实现,因此在同一个行为发生的时候,可以根据条件挑选任意一个实现来进行相应的处理。 如果行为是平行性的,则不可相互替换的;如果行为是平等性的,则是可以相互替换的。 状态决定行为 状态之间可以转换 状态之间的变换由外界控制 来源: oschina 链接: https://my.oschina.net/u/660460/blog/652365

Atomic state storage in Python?

纵然是瞬间 提交于 2019-12-04 21:32:18
I'm working on a project on an unreliable system which I'm assuming can fail at any point. What I want to guarantee is that if I write_state and the machine fails mid-operation, a read_state will either read a valid state or no state at all. I've implemented something which I think will work below -- I'm interested in criticism of that or alternative solutions if anyone knows of one. My idea: import hashlib, cPickle, os def write_state(logname, state): state_string = cPickle.dumps(state, cPickle.HIGHEST_PROTOCOL) state_string += hashlib.sha224(state_string).hexdigest() handle = open('%s.1' %

How to prevent $state from refreshing any Component that does not rely on the $state.var being changed?

蹲街弑〆低调 提交于 2019-12-04 20:15:58
We're using Angular-ui-router for our app state management. A problem we're having is that every component refreshes when the $state changes, even if it's a variable that is updated that does not exist/not used in some components. For example, we have a TickersPanel and a TagsPanel. When a Ticker is selected, the TagsPanel should be updated and refreshed, however when a tag is selected in the TagsPanel, the TickersPanel should NOT refresh, but it currently does. I found out that { notify: false } is another object that can be passed in. However once I do that, NO components will refresh. const

Google OAuth 2 and state parameter values need to be registered in redirect url

不羁岁月 提交于 2019-12-04 19:56:03
问题 The state parameter according to the Google Oauth 2.0 docs: Indicates any state which may be useful to your application upon receipt of the response. The Google Authorization Server roundtrips this parameter, so your application receives the same value it sent. Possible uses include redirecting the user to the correct resource in your site, nonces, and cross-site-request-forgery mitigations. I'd like to use the state parameter as a means to know which subdomain the original oauth request was