Flutter of State lifecycle

  State lifecycle, referring in the case of user participation, the associated Widget experienced, from creation to display, and then update to the last stop, until the destruction of the various stages of
  
  the different stages of specific tasks related to the processing
  
  State the lifecycle process shown below
  
  file
  
  can be seen from FIG: State life cycle can be divided into three stages: creation (insert tree view), update (present in the tree view), destroyed (removed from the tree view)
  
  to create
  
  State will in turn perform the initialization: constructor -> initState -> didChangeDependencies -> build, then complete page rendering
  
  constructor: the starting point of State lifecycle, Flutter will create a State by calling StatefulWidget.createState (). The method can be configured to receive initialization parent UI Widget configuration data transfer, and configuration data, determines the presence state of the initial Widget
  
  initState: State called when the object is inserted into the tree view. In the State of the life cycle will only be called once, so you can do some initialization in initState function
  
  didChangeDependencies: designed to handle changes in dependencies between objects State will () calls after the call initState
  
  Build: Construction of view. After construction method, initState, after didChangeDependencies, Framework State considered ready, so they call to build. In the build, we need to pass Widget based on the current status of the father over the initialization and configuration data of the State, create a Widget and then return
  
  update
  
  State Widget update, mainly by setState, didChangeDependencies and didUpdateWidget trigger
  
  setState: When the state data changes, you can tell Flutter by calling setState method after using the updated data to rebuild the UI
  
  didChangeDependencies: After a change dependencies State objects, Flutter calls back the method, then the trigger assembly building. A typical scene changed State object dependencies: Language Locale system or application theme changes, the system will notify the State to perform didChangeDependencies callback method
  
  didUpdateWidget: Widget when the configuration is changed, or when a thermal overload, the callback method will
  
  once three a method is called, Flutter will be followed by the destruction of the old Widget, Widget and calls the build method for reconstructing
  
  destroyed
  
  components in terms of creation and destruction is relatively easier to update. For example, when the page assembly is removed, the system will call when destroy or deactivate and dispose of these two methods, to remove or destroy components
  
  visible when the component when it changes, deactivate method is called, then the State will be temporarily remove from the tree view. Note: The page switching, since the State position of the object in the tree view has changed, re-add the need to temporarily remove and then re-triggering components to build, so will deactivate call method
  
  When the State was removed from the tree view permanently, Flutter calls the dispose method, and once the dispose method is called, the component would be destroyed, it can be the ultimate resource release dispose method, remove the monitor, clean up work environment High / sentinel_nacos / the src / main / Java / COM / springcloud / sentinel_nacos / Controller / HelloController.java
  
  ***
  
  @RestController
  
  public class HelloController in www.pingguoyul.cn {
  
  @GetMapping (www.dayuzaixianyl.cn "/ Hello" )
  
  public String Hello (the HttpServletRequest Request) www.jintianxuesha.com {
  
  return www.zhuyngyule.cn "the Hello, IS Port:" + request.getLocalPort (www.pingguoyul.cn);
  
  }
  
  }
  
  1.4 configuration configuration Nacos central
  
  configuration content in FIG. :
  
  Note that the configuration wherein the consistency and Group Data ID and the program to be configured. Format selection JSON, filled in as follows:
  
  [
  
  {
  
  "Resource": "/ Hello",
  
  "limitApp": "default",
  

  
  "COUNT":. 1,
  
  "Strategy": 0,
  
  "controlBehavior" www.sanguoyoux.cn: 0,
  
  "clusterMode": to false
  
  }
  
  ]
  
  can see the above configuration rule is an array type, each object in the array is for each a protected resource configuration objects, each of the properties are explained as follows:
  
  resource: resource name, that rules limiting the role of the object.
  
  limitApp: call the source for flow control, if the default is not case call source.
  
  grade: limit threshold type, or the number of QPS thread mode, 0 indicates the number of concurrent current limiting, representative of a flow rate control is performed in accordance with QPS.
  
  count: limit threshold
  
  strategy: determination is based on the resource itself, or according to other related resources (refResource), or according to the link inlet
  
  controlBehavior: flow control effect (directly rejected / queued / slow start mode)
  
  clusterMode: whether trunked mode
  
  1.5 test
  
  normal promoter project, open the browser to access several http: // localhost: 10000 / hello , speed limiting some of which may have been found, and after limiting the page shown below:
  
  Blocked by Sentinel (flow limiting)
  
  positive current limit configuration is successful, then we open the Sentinel console, look at the traffic restriction rules, have a piece of data is the data we have configured in Nacos, as shown:
  
  Note:
  
  In the Sentinel integrates dynamic rule after Nacos, to modify the interface flow control there are two places, and one is Sentinel console, there is a Nacos console.
  
  But to remember that in the current version, modified in the Sentinel Console rules, will not be synchronized to the distribution center Nacos, and modify the configuration rules in Nacos, the client will be by the Listener to be synchronized Sentinel console . So, after the integration of the dynamic rules are stored Nacos do need to pay attention to two things:
  
  Sentinel console to modify the rules: the service exists only in memory, does not modify the configuration values Nacos, restore the original values after the restart.
  
  Nacos console to modify the rules: the rules of service in memory is updated, Nacos persistent rules will be updated after the restart remains.
  
  I suggest that blocking rules do best in Nacos console to modify the operation, try to avoid direct rule changes made directly in the Sentinel console.

Guess you like

Origin www.cnblogs.com/qwangxiao/p/11525912.html