当前位置:网站首页>Swiftui development experience: data layer of application design for offline priority

Swiftui development experience: data layer of application design for offline priority

2022-06-26 10:31:00 Knowledge fatness

Internet age , Why do I need to launch offline applications ? Let's discuss its importance and implementation through an example .

background

well , Let's start with the concept of offline priority applications .

Offline priority applications are architected in such a way that even if your Internet is in poor condition or has no Internet at all , They can also continue to work .

Have you ever thought about it Evernote Wait for note application or Whatsapp Wait for chat apps to continue working without the Internet ? You can not only use existing data , You can also send messages or add comments , It synchronizes when the Internet is available .

It's not magic ! This is how these applications are designed .

Offline priority applications are very enjoyable to use , And it will certainly make users happy , Because when they want to take action , They will never be stopped by the Internet , Especially in a world where everyone has very limited time !

Now we understand the concept and its importance , Let's see how to start creating these types of applications !

How to build the first offline application

There are many ways to create offline first applications , But ideally , In my submission UI You shouldn't care about it , The logic should be completely encapsulated in the data layer .

today , We will explore ways in which the data layer is fully responsible for creating offline first experiences .

 Insert picture description here

Using this method , The data layer basically provides an interface with UI Repository for tier interaction . The repository then handles both local and remote storage .

To make a long story short , There are... In the data layer 3 A component :

  • Repository — towards UI The layer provides data obtained from local storage . It also notifies remote storage when a refresh is required .
  • The local store
原网站

版权声明
本文为[Knowledge fatness]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260940152585.html