颤振稳定性叶瓣图_颤振异步redux graphql

2024-03-03 09:59

本文主要是介绍颤振稳定性叶瓣图_颤振异步redux graphql,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

颤振稳定性叶瓣图

Developing an application in Flutter using Async Redux and GraphQL.

使用异步Redux和GraphQL在Flutter中开发应用程序。

Image for post

First of all, if you fell here with a parachute, what will be shown here is just a proof of concept (PoC) to validate an idea. It will probably be useful for you to understand and abstract new knowledge.

首先,如果您是带着降落伞降落在这里的,那么这里显示的仅仅是概念验证(PoC)来验证一个想法。 这可能对您理解和抽象新知识很有用。

This is a version translated from Portuguese 🇧🇷 to English. the original article you can find here: https://medium.com/@oguibueno/flutter-async-redux-graphql-b581d8097b84

这是从葡萄牙语translated到英语的版本。 您可以在此处找到原始文章: https : //medium.com/@oguibueno/flutter-async-redux-graphql-b581d8097b84

(Flutter)

It is an open source SDK to develop in Dart, an object-oriented programming language created by Google, where the first version was launched in 2013 with the main intention of replacing JavaScript. In 2018, version 2.0 was released, fully optimised, and improved in many ways, one of which is the client-side focus on apps, web, and desktop.

它是一个开放源代码的SDK,可以在Dart中开发,Dart是Google创建的一种面向对象的编程语言,该版本的第一版于2013年推出,其主要目的是取代JavaScript。 2018年,发布了2.0版本,并在许多方面进行了全面优化和改进,其中之一是客户端侧重于应用程序,Web和桌面。

Flutter does not use native components, so they are all rendered by the graphics engine itself, such as buttons, text, media, background, etc. However, it was inspired by React, where the components (A.K.A Widgets) are declaratively written, and of course, it has a hot reload.

Flutter不使用本机组件,因此它们都是由图形引擎本身呈现的,例如按钮,文本,媒体,背景等。但是,它是受React启发的,其中声明性地编写了组件(AKA小部件),并且当然,它具有热装。

Image for post

国家管理 (State Management)

In an application, State Management is the interface between your data (from whatever your backend is) or local change and the representation of that data with user interface elements on the front end. State can keep data from different components in sync, because each state update renders all relevant components again. State management can also serve as a means of communication between different components.

在应用程序中,状态管理是数据(来自后端的任何内容)或本地更改与数据的表示之间的接口,该数据具有前端的用户界面元素。 状态可以使来自不同组件的数据保持同步,因为每个状态更新都会再次呈现所有相关组件。 状态管理还可以用作不同组件之间的通信方式。

Image for post

In Flutter, there are some options to manage the state, and in the link below, you can find those recommended by the Flutter team itself.

在Flutter中,有一些选项可以管理状态,在下面的链接中,您可以找到Flutter团队本身推荐的选项。

异步Redux (Async Redux)

As I have already worked with Redux and React, I looked for a library that would allow me to develop in the same “way” because I already know the power that Redux has as a state manager. So, I found a library called Flutter Redux, but it has a lot of boilerplate, which ended up making me look for another one. The one I liked the most is called Async Redux, very easy to understand and implement, has many features and the documentation is something incredible! Congratulations Marcelo Glasberg for the great job and thanks for the code review on this app!

在使用Redux和React之前,我一直在寻找一个可以让我以同样的“方式”进行开发的库,因为我已经知道Redux作为状态管理器所具有的功能。 因此,我找到了一个名为Flutter Redux的库,但是它有很多样板,最终使我不得不寻找另一个库。 我最喜欢的一个称为Async Redux,非常易于理解和实现,具有许多功能,文档令人难以置信! 祝贺Marcelo Glasberg的出色工作,并感谢您对该应用程序进行的代码审查!

Image for post

GraphQL (GraphQL)

It is a query language for APIs that was developed and launched by Facebook in 2015. Its main tools are: Query, Mutation and Subscription. In this example, we will only use queries and mutations.

它是Facebook在2015年开发和发布的一种API查询语言。它的主要工具是:查询,变异和订阅。 在此示例中,我们将仅使用查询和变异。

Image for post

In April 2019 I gave a lecture on the .NET Architecture trail, at The Developers Conference in Florianópolis. I talked about how to evolve an existing REST architecture, with a practical example in .NET Core. Below I leave the repository:

在2019年4月,我在弗洛里亚诺波利斯的开发人员会议上进行了有关.NET体系结构跟踪的演讲。 我通过.NET Core中的实际示例讨论了如何发展现有的REST体系结构。 下面,我离开存储库:

https://github.com/oguibueno/TDC2019

https://github.com/oguibueno/TDC2019

动手! (Hands on!)

The project is structured as follows, with the separation between business and client. Where the business has our state manager and access to the API and the client has our Widgets where there is not much logic and coupling.

该项目的结构如下,业务与客户之间是分离的。 在企业拥有我们的状态管理器并可以访问API的地方,而客户拥有我们的Widget的地方,这些地方没有太多的逻辑和耦合。

Image for post

The libraries in which they were used can be found in the pubspec.yaml file.

可以在pubspec.yaml文件中找到使用它们的库。

async_redux: 2.1.5graphql: ^2.1.0

async_redux:2.1.5graphql:^ 2.1.0

First, we will “plug in” Async Redux at the root of our main.dart application. This will make it possible for our entire application to “access” the data of our state.

首先,我们将在main.dart应用程序的根目录下“插入”异步Redux。 这将使我们整个应用程序可以“访问”我们状态的数据。

Image for post

The main entry will be the TodosConnector, which works as a kind of “plug” for our TodosPage and TodoModel, and this means that our Widget has no dependency on the state manager. Making our code much cleaner and more modularised.

主要条目将是TodosConnector ,它充当TodosPageTodoModel的一种“插件”,这意味着我们的Widget不依赖状态管理器。 使我们的代码更简洁,更模块化。

AppState is the key part of Async Redux, as it is there that we can access information about our state. There will be only one AppState for the entire application.

AppState异步Redux的关键部分,因为在那里我们可以访问有关状态的信息。 整个应用程序只有一个AppState

The copy method is responsible for generating a new state, making a “run-in” between the old and the new, on lines 13 and 14.todoList is initialised with an empty Todo array, on line 16.

copy方法负责在第13行和第14行生成新状态,在新旧状态之间进行“磨合” 。todoList在第16行使用空的Todo数组进行初始化。

Image for post

This is where all actions that TodosPage can do are mapped, thus injecting it into its constructor.

这是TodosPage可以执行的所有操作的映射,因此将其注入到其构造函数中。

Image for post

For the listing to contain data when opening the application, we will use onInitialBuild to execute the query in the GraphQL API, as soon as the Widget is built for the first time.

为了使清单包含打开应用程序时的数据,我们将在第一次构建Widget时使用onInitialBuildGraphQL API中执行查询。

It is in TodoModel that we map the necessary actions to dispatch. It is also mapped here, the data that we want to expose in this context, coming from our state. In this case, we have a property called todoList where it is populated from the state.todoList that comes from fromStore(). Both dispatch and state are injected by Async Redux itself, which greatly reduces the amount of code, making it much cleaner and easier to read.

TodoModel中 ,我们映射了要调度的必要动作。 它也映射到这里,我们要在这种情况下公开的数据来自我们的州。 在这种情况下,我们有一个名为todoList的属性,该属性由来自fromStore()state.todoList填充。 调度状态都由Async Redux本身注入,这大大减少了代码量,使其更简洁易读。

Image for post

We need to define a reducer that is asynchronous, so we define it as async. Since the call to the GraphQL endpoint is Future, then we must await this external query method on line 29.

我们需要定义一个异步的减速器 ,因此我们将其定义为异步。 由于对GraphQL端点的调用是Future ,因此我们必须在第29行上等待此外部查询方法。

https://pub.dev/packages/async_redux#async-reducer

https://pub.dev/packages/async_redux#async-reducer

Image for post

QueryOptions is an object that is sent to GraphQL, containing, in this case, a query, which is located on line 10.

QueryOptions是一个发送到GraphQL的对象,在这种情况下,该对象包含位于第10行的查询。

GraphQLClientAPI is the configuration of our API, I put in line 7 the URL of the Android emulator, and in line 8, the URL of the iOS emulator.

GraphQLClientAPI是我们API的配置,我在第7行中输入了Android模拟器的URL,在第8行中输入了iOS模拟器的URL。

Image for post

If the request has no error, the result is converted into a list, mapped to the Todo type, and thus, we update our state, making a state.copy.

如果请求没有错误,则将结果转换为列表,映射为Todo类型,因此,我们更新状态,制作一个state.copy

This is the Todo our model.

这就是Todo我们的模型。

Image for post

After requesting the API, the reducer will create a new copy with the new status, with the changes made there. As our TodosPage is plugged through TodoModel with StoreConnector, and todoList was injected in the construction of TodosPage, we populate the ListView with the data coming from the API and thus cards are assembled, in line 31.

请求API后, Reducer将创建具有新状态的新副本,并在其中进行更改。 当我们的TodosPage通过StoreConnector通过TodoModel插入,并且todoList被注入到TodosPage的构造中 ,我们用来自API的数据填充ListView,从而在第31行中组装了卡。

PS: if you don’t want to update the status, just return null.

PS:如果您不想更新状态,请返回null。

Image for post

Our main listing looks like this:

我们的主要清单如下:

Image for post

The GraphQL API was built with Node and Express. The endpoint shown in the example above, used the query all within the schema below.

GraphQL API是使用NodeExpress构建的。 上例中显示的端点在以下模式中全部使用了查询。

Image for post

After defining the schema, line 45 defines the query, which consumes todosMock, an array initialised with 3 items. After root is defined, it is injected into the Express app and then exposed at endpoint /graphql, on port 4000.

在定义了模式之后 ,第45行定义了查询,该查询使用了todosMock ,这是一个初始化了3个项目的数组。 定义root后,将其注入Express应用程序中,然后在端口4000的端点/ graphql处公开。

Image for post

On GitHub, you will find the complete CRUD for this application.

GitHub上 ,您将找到此应用程序的完整CRUD

Thanks!

谢谢!

Special thanks to Marcelo Glasberg, creator of Async Redux, who was attentive and made himself available to review the Flutter code shown in this publication.

特别感谢Async Redux的创建者Marcelo Glasberg ,他非常专心,可以随时查看本出版物中显示的Flutter代码。

的GitHub (GitHub)

Flutter application repository

Flutter应用程序存储库

Node API repository with GraphQL

带有GraphQL的Node API存储库

联络人 (Contacts)

LinkedIn

领英

Twitter

推特

有用的链接 (Useful links)

翻译自: https://levelup.gitconnected.com/flutter-async-redux-graphql-7c0db2e4d2be

颤振稳定性叶瓣图


http://www.taodudu.cc/news/show-8479337.html

相关文章:

  • matlab动力学共振颤振研究
  • 颤振稳定性叶瓣图_颤振主题系统
  • 颤振稳定性叶瓣图_颤振性能优化
  • 双路颤振频率Hz可设置比例阀放大器
  • 深度聚类paper汇总
  • paperwithcode
  • AAAI2021 accepted paper list
  • 使用Tex 撰写paper-TexStudio设置默认字体样式大小等
  • Raphael学习之Paper常用API(四)
  • 如何写paper
  • Paper:txyz_ai(一款帮助科研人员阅读PDF论文ChatGPT利器)的简介、安装、使用方法之详细攻略
  • 抑郁症康复日记
  • 计算机抑郁症与干涉相关的,抑郁症
  • matlab 自带的数据集fisheriris
  • 【文末福利】为什么我们要掌握Linux系统编程?
  • 什么是TCP的混合型自时钟
  • 炮打洋鬼子创作总结
  • oracle 过滤字段中的中文,不再洋不洋土不土
  • field list什么意思_闲话Python之range()到底是个什么玩意儿
  • AI全栈大模型工程师(二十二)什么是模型训练
  • 什么是mysql锁_简单理解MySQL锁
  • 什么是MAS : 一种目标管理工具和方法
  • 什么是接口API
  • python函数一般不能_Python程序中对一个函数的调用不能出现在该函数的定义之前...
  • 打字练习软件 Type Fu mac中文版技能介绍
  • 打字练习(Python代码模拟打字练习软件效果)
  • 增长率超60%,工业机器人进入新一轮爆发期!
  • 数据结构与算法-动态规划-机器人达到指定位置方法数
  • 机器人学习之项目- Project5:KUKA Robot Challenge(一)
  • 机器人学习-路径规划实验(一)
  • 这篇关于颤振稳定性叶瓣图_颤振异步redux graphql的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



    http://www.chinasem.cn/article/769271

    相关文章

    Linux系统稳定性的奥秘:探究其背后的机制与哲学

    在计算机操作系统的世界里,Linux以其卓越的稳定性和可靠性著称,成为服务器、嵌入式系统乃至个人电脑用户的首选。那么,是什么造就了Linux如此之高的稳定性呢?本文将深入解析Linux系统稳定性的几个关键因素,揭示其背后的技术哲学与实践。 1. 开源协作的力量Linux是一个开源项目,意味着任何人都可以查看、修改和贡献其源代码。这种开放性吸引了全球成千上万的开发者参与到内核的维护与优化中,形成了

    9 个 GraphQL 安全最佳实践

    GraphQL 已被最大的平台采用 - Facebook、Twitter、Github、Pinterest、Walmart - 这些大公司不能在安全性上妥协。但是,尽管 GraphQL 可以成为您的 API 的非常安全的选项,但它并不是开箱即用的。事实恰恰相反:即使是最新手的黑客,所有大门都是敞开的。此外,GraphQL 有自己的一套注意事项,因此如果您来自 REST,您可能会错过一些重要步骤!

    Rust:Future、async 异步代码机制示例与分析

    0. 异步、并发、并行、进程、协程概念梳理 Rust 的异步机制不是多线程或多进程,而是基于协程(或称为轻量级线程、微线程)的模型,这些协程可以在单个线程内并发执行。这种模型允许在单个线程中通过非阻塞的方式处理多个任务,从而实现高效的并发。 关于“并发”和“并行”的区别,这是两个经常被提及但含义不同的概念: 并发(Concurrency):指的是同时处理多个任务的能力,这些任务可能在同一时

    玩转Web之easyui(二)-----easy ui 异步加载生成树节点(Tree),点击树生成tab(选项卡)

    关于easy ui 异步加载生成树及点击树生成选项卡,这里直接给出代码,重点部分代码中均有注释 前台: $('#tree').tree({ url: '../servlet/School_Tree?id=-1', //向后台传送id,获取根节点lines:true,onBeforeExpand:function(node,param){ $('#tree').tree('options'

    【Python】 异步编程

    【Python】 异步编程 1. nest_asyncio基础定义2. nest_asyncio 举例实现基本用法 1. nest_asyncio基础定义 nest_asyncio.apply() 是 Python 编程中与异步编程相关的一个调用,它用于解决某些特定环境下的异步编程问题。下面是对这个调用的详细解释: nest_asyncio 模块:这是一个第三方库,它提供

    AJAX:如何编写一个关于AJAX的Hello World?(ajax发送异步请求(四步操作))

    用到的一个Servlet类: package cn.edu.web.servlet;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.annotation.WebServlet;import javax.servlet.http.HttpServlet;impor

    彻底征服 React.js + Flux + Redux【讲师辅导】-曾亮-专题视频课程

    彻底征服 React.js + Flux + Redux【讲师辅导】—74574人已学习 课程介绍         【会员免费】链接 http://edu.csdn.net/lecturer/585 右侧办理会员卡。办会员卡可咨询 QQ 1405491181 。 会员可免费学习已发布的全部课程,和在会员有效期内讲师新发布的全部课程 ,承诺每个月至少增加价值500元+ 的新课程。 R

    iOS Runloop面试题(什么是异步绘制?)

    什么是异步绘制? 异步绘制,就是可以在子线程把需要绘制的图形,提前在子线程处理好。将准备好的图像数据直接返给主线程使用,这样可以降低主线程的压力。 异步绘制的过程 要通过系统的 [view.delegate displayLayer:] 这个入口来实现异步绘制。 代理负责生成对应的 Bitmap设置该 Bitmap 为 layer.contents 属性的值。

    协程: Flow 异步流 /

    以异步方式返回多个返回值的方案: 在 Kotlin 协程 Coroutine 中 , 使用 suspend 挂起函数 以异步的方式 返回单个返回值肯定可以实现 , 如果要 以异步的方式 返回多个元素的返回值 , 可以使用如下方案 : 集合序列Suspend 挂起函数Flow 异步流 同步调用返回多个值的弊端   鸣谢: mAndroid面试题之Kotlin异步流、冷流Flow

    VUE\JS处理在循环中异步和同步执行的问题

    业务场景: 1、有一个组别集合,每一个小组别对象里面有一个数据集合,需要循环去校验每个不同组里的数据(不同组合因为一些特殊属性不能合并到一个组里),全都符合就通过验证,去处理后续业务。 2、现在,在校验规则方法里对一个集合里的每一条数据进行强校验和弱校验,弱校验需要在提升框放入确定的操作按钮,允许通过,再循环到下一条数据的验证。 代码分析 1、涉及到组别集合的循环、组别内部数据的循环,循环套