小编fre*_*aso的帖子

在SPA(html5单页面应用程序)中是否存在同步本地和远程数据的最佳实践/模式?

我正在用jqueryMobile + knockout + breeze + WebAPI编写一个简单的"todo - helloworld"来了解移动环境中的SPA(单页应用程序)(不可靠的互联网连接)

要启用脱机使用,WebApp将利用

  • 应用缓存
  • localStorage的

应用程序应尽可能使用远程数据库来加载和保存数据,但应该能够在脱机时无缝切换到localstorage并在重新联机时同步本地/远程更改.

现在回到问题:App将使用Breeze的EntityManager来管理数据(本地缓存和远程同步)

  • "remoteDb"

为了缓解不一致/并发问题,我将使用2个localstorage密钥:

  • "localDb"表示远程数据库的本地副本(待办事项列表)
  • "localPendingChanges"用于更改App无法提交到远程数据库的更改

所以流程或多或少会(伪代码):

LoadData
  if(online)
    load remoteDb
    save localDb                   // save a local copy of the fresh loaded remotDb
    if(localPendingChanges)
      load localPendingChanges     // we are merging in the Breeze entityManager remote data with localPendingChanges
      Savedata                     // we are online and we have pending changes, so we should sync everything back to the remoteDb as soon as possible
  if(offline)
    load localDb
    if(localPendingChanges)
      load localPendingChanges     // …
Run Code Online (Sandbox Code Playgroud)

local-storage singlepage data-synchronization single-page-application breeze

10
推荐指数
1
解决办法
3205
查看次数

Breeze实体与打字稿

我正在使用Breeze + Typescript + Knockout进行Spa,我面临以下问题:当我使用EntityManager.createEntity创建一个新实体时,typescript不允许我使用Breeze从元数据生成的observable.Typescript只"看到""entityAspect"和"entityType"属性.我正在使用DefinitelyTyped的类型定义.任何帮助是极大的赞赏!

knockout.js single-page-application typescript breeze

4
推荐指数
1
解决办法
1870
查看次数

用户删除时,Firebase身份验证未撤消?

我遇到了使用电子邮件/密码登录Firebase简单登录的奇怪行为:如果我使用现有用户帐户登录,我可以写入Firebase ref(即$ root/list/$ item).如果没有,我没有按预期的写访问权限(Firebase规则似乎没问题),但是如果客户端已登录,并且我同时从Firebase Forge(Auth页面)删除用户,则连接的客户端仍然可以写入访问权限. Firebase参考!它是设计还是错误?谢谢.

这是规则:

{
  "rules": {
    ".read": true,
    "list": {
      "$item": {
        ".write": "auth != null && newData.child('author').val() == auth.id",
        ".validate": "newData.hasChildren(['author', 'content'])",
        "author": {
          ".validate": "newData.val() == auth.id"
        },
        "content": {
          ".validate": "newData.isString()"
        }
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security

4
推荐指数
1
解决办法
3710
查看次数

UWP 拖放自定义类型/类

你好,我正在尝试在 2 个 GridView 之间启用拖放功能,我设法使用“DataPackage”类的自定义类型(SetText、SetBitmap 等)来做到这一点,但我不知道该怎么做这是一个自定义类/类型。两个 GridView 都将数据绑定到同一个自定义类(只有几个属性,int、string、bitmapimage),我只是想直接将此数据项从一个 GridView 拖动到另一个。非常感谢您的帮助!

c# drag-and-drop win-universal-app

4
推荐指数
1
解决办法
2250
查看次数

WKWebView使用LoadFileUrl加载本地内容

我正在尝试使用LoadFileUrl方法在WKWebView中加载本地html文件,但我得到的只是一个空白视图.这是一个Xamarin.Mac应用程序(还没有Sandbox).

WKWebViewConfiguration conf = new WKWebViewConfiguration();
WKWebView www = new WKWebView (View.Frame, conf);
View = www;

string index = Path.Combine (NSBundle.MainBundle.BundlePath, "WebApp/Index.html");
string webAppFolder = Path.Combine (NSBundle.MainBundle.BundlePath, "WebApp");

www.LoadFileUrl (new NSUrl ("file://"+index), new NSUrl ("file://"+webAppFolder));
Run Code Online (Sandbox Code Playgroud)

使用"LoadRequest"从远程服务器加载网页工作得很好.

"Index.html"文件的构建操作是"BundleResource"

感谢你的帮助!

c# xamarin xamarin.mac wkwebview

3
推荐指数
1
解决办法
2906
查看次数