当前位置:网站首页>SwiftUI 开发经验之为离线优先的应用程序设计数据层
SwiftUI 开发经验之为离线优先的应用程序设计数据层
2022-06-26 09:40:00 【知识大胖】
互联网时代,为什么需要线下首发应用?让我们通过一个例子来讨论它的重要性和实现。
背景
好的,让我们从离线优先应用程序的概念开始。
离线优先应用程序的架构方式是即使在您的互联网状况不佳或根本没有互联网的情况下,它们也能继续正常工作。
有没有想过Evernote等笔记应用或Whatsapp等聊天应用如何在没有互联网的情况下继续工作?您不仅可以使用现有数据,还可以发送消息或添加注释,当互联网可用时它会同步。
那不是魔法!这些应用程序就是这样设计的。
离线优先的应用程序使用起来非常愉快,并且肯定会让用户感到高兴,因为当他们想要采取行动时,他们永远不会被互联网阻止,尤其是在每个人时间都非常有限的世界里!
现在我们了解了这个概念及其重要性,让我们看看如何开始创建这些类型的应用程序!
如何构建离线第一个应用程序
有很多方法可以创建离线优先的应用程序,但理想情况下,我认为 UI 不应该关心它,逻辑应该完全封装在数据层中。
今天,我们将探索数据层完全负责创建离线优先体验的方法。

使用这种方法,数据层基本上提供了一个与 UI 层交互的存储库。然后存储库处理本地存储和远程存储。
总而言之,数据层中有 3 个组件:
- Repository — 向 UI 层提供从本地存储中获取的数据。它还会在需要刷新时通知远程存储。
- 本地存储
边栏推荐
- echo $?
- Automated testing -- on the coexistence of Unitest and pytest initialization
- MySQL第十次作业-视图
- Basic string operations in C
- Get the clicked position in the recyclerview
- Day 3 array, pre post, character space, keyword and address pointer
- MySQL learning summary
- Searchview click failure
- 2. 合并两个有序数组
- Threading model in webrtc native
猜你喜欢

MySQL第六次作业-查询数据-多条件

瑞萨电子面向物联网应用推出完整的智能传感器解决方案

Record the handling of oom problems caused by too many threads at one time

Under the double reduction, the amount of online education has plummeted. Share 12 interesting uses of webrtc

A list of common methods for customizing paint and canvas of view

Small example of SSM project, detailed tutorial of SSM integration

C中字符串基本操作

Solution to network request crash in retrofit2.8.1

Selection of webrtc video codec type VP8 H264 or other? (openh264 encoding, ffmpeg decoding)

Call API interface to generate QR code of wechat applet with different colors
随机推荐
Pytest configuration file
MySQL第八次作业
Win10安装tensorflow-quantum过程详解
Configuration internationale
Servlet learning notes II
In the fragment, the input method is hidden after clicking the confirm cancel button in the alertdialog (this is valid after looking for it on the Internet for a long time)
MySQL项目8总结
MySQL第四章总结
方法区里面有什么——class文件、class文件常量池、运行时常量池
MySQL 11th job - view application
[sans titre]
Extracting public fragments from thymeleaf
What is the web SSH service port of wgcloud
P1296 whispers of cows (quick row + binary search)
什么是僵尸网络
Today's headline adaptation scheme code
Glide's most common instructions
【Leetcode】76. 最小覆盖子串
MySQL第十二次作业-存储过程的应用
MySQL第十一作业-视图的应用