简体   繁体   English

Strophe,belimberjs和jquery-mobile

[英]Strophe, backbonejs and jquery-mobile

I want to build a MVC structured mobile app with backbonejs. 我想用骨干网构建一个MVC结构的移动应用程序。 I searched the web for information and I only found the strophe backbone plugins for: 我在网上搜索了信息,但只找到了strophe骨干插件:

strophe.pubsub.js
strophe.forms.js
strophe.vcard.js
strophe.private.js
strophe.roster.js

Can I run into problems with using backbone.js and Strophe together? 我可以同时使用骨干网和Strophe遇到问题吗?

You are probably referring to my own strophe.plugins . 您可能是指我自己的strophe.plugins Those will of course work fine out of the box, in addition they are fully test-covered. 当然,这些功能开箱即用,而且经过全面测试。 You can of course use any other plugin with Strophe, it does not collide with Backbone in any way. 您当然可以在Strophe中使用其他任何插件,但它不会以任何方式与Backbone冲突。

Keep in mind strophe.plugins while independently working, were written to be used together with Backbone.xmpp . 请记住,strophe.plugins在独立工作时被编写为与Backbone.xmpp一起使用。 I wrote that library to allow you to sync your Backbone models/collections with XMPP PubSub nodes, giving you real-time events on all your clients. 我编写该库是为了使您可以将Backbone模型/集合与XMPP PubSub节点同步,从而为所有客户端提供实时事件。

Here's a demo of how that works in practice with two clients. 这是一个演示如何与两个客户一起实践的示例

No problems using the libraries together. 一起使用库没有问题。

About 12 months ago, I was part of a small team who used Backbone.js and strophe to implement a one page social networking web app using xmpp / ejabberd as the primary messaging platform.... we ended up redesigning it, replacing ejabberd for a custom RESTful api ( http://beta.playup.com ). 大约12个月前,我是一个小团队的成员,该团队使用Backbone.js和strophe来使用xmpp / ejabberd作为主要消息传递平台来实现一页社交网络应用程序。...我们最终对其进行了重新设计,为定制的RESTful api( http://beta.playup.com )。

There are a few issues you need to think about - esp when writing a one page app, such as connection management. 您需要考虑一些问题-尤其是在编写一页应用程序时,例如连接管理。 As you are creating a stophe connection client side, you need a way to re-connect the users account on page refresh (as the js is obviously reloaded). 当您创建一个stophe连接客户端时,您需要一种在页面刷新时重新连接用户帐户的方法(因为显然已重新加载了js)。

We also ran into memory leak problems. 我们还遇到了内存泄漏问题。 Be careful when throwing custom events in Backbone Views... as you will need to manually unbind them when you are done with a view. 在“主干网视图”中引发自定义事件时要小心...,因为在完成视图后将需要手动取消绑定它们。 If you don't the view remains active through the bound event, and is not GC'd. 如果不这样做,则视图在绑定事件中保持活动状态,并且不会进行GC处理。 This means you probably have to introduce a bit of a lifecycle in your app. 这意味着您可能必须在应用程序中引入一些生命周期。

Generally speaking though, this will only be a problem if you are doing a web app of some size. 不过,一般来说,只有在您使用某种规模的Web应用程序时,这才是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM