delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

What's the diffrerence between Meteor and MeteorSingleton? How to increase lifetime of connection? #51

Closed Rokeder closed 8 years ago

Rokeder commented 8 years ago

What's the diffrerence between Meteor and MeteorSingleton? For example:

If i will initialize variable like this: Meteor mMeteor = new MeteorSingleton.createInstance(this,"some_web_socket"); Is it right implementation? If not what case will be right?

ocram commented 8 years ago

Thanks for your question!

Singleton access should be well-documented in the README: https://github.com/delight-im/Android-DDP/blob/76bde3f493a5fcf8ac0c4ef79d99911eca30a9e3/README.md#usage

If you don't know what the Singleton pattern is for, you may not really need it, perhaps.

Usually, the normal usage is what you need. But when you need to access the same Meteor instance from multiple Activity instances, for example, you may find the singleton useful.

If using the singleton, you call createInstance(...) only once. Afterwards, you have to call getInstance() or just use the instance that you assigned to your variable (mMeteor).

Does that help?