Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON.js support for managing connection to WL JSON Store. #13

Open
andrewferrier opened this issue Nov 8, 2013 · 4 comments
Open

JSON.js support for managing connection to WL JSON Store. #13

andrewferrier opened this issue Nov 8, 2013 · 4 comments
Assignees
Labels

Comments

@andrewferrier
Copy link

It would be a huge help if JSON.js could abstract away some of the mechanics of getting the WL JSON Store in the first place. WL.JSONStore.init() took me a long time to get working (the docs weren't clear that it was returning a Deferred), and I still can't get WL.JSON.get() to work at all (instead, I am using the value returning from init's Deferred, which contains handles to all the collections. Abstracting out this flaky bit (which also needs to be wrapped in an onDeviceReady callback) would be a real time-saver.

@ghost ghost assigned chrisfelix82 Nov 8, 2013
@kfbishop
Copy link
Contributor

kfbishop commented Nov 8, 2013

Thx Andrew

@kfbishop
Copy link
Contributor

kfbishop commented Nov 8, 2013

[From ChrisF note]
Thanks for tracking the issues on GitHub. With respect to the enhancement of abstracting away the initialisation of the WL.JSONStore.init(), I had done this in an earlier iteration of the code. The reason I opted out of doing that was because the way a store was initialised changed from Worklight 5 to 6, so I thought leaving it outside the store may be better. Also, the initialisation of a JSONStore may require tie in with authentication if the store is encrypted, and many stores may need to be opened at once because of this. Given these facts, I didn't add the initialisation into dworklight/store/JSON. I am open to suggestions though on how we can simplify things given these use cases.

Yesterday I added some functionality to assist in using the store in dojox/app based applications, where you would like to define the store in config.json. Now you can define an entry like so:

"Note" : {
        "type": "dworklight/store/JSON",
        "observable": true,
        "params": {
            "collectionInitClass" : "commonapp/LocalStorage",
            "collectionInitMethod" : "note"
        }
    } 

The addition of collectionInitClass and collectionInitMethod, allow you to tell the store which class and method to call to provide the JSONStore collection if one is not set the first time the store is used in the app. This means that you do not have to worry about manually setting the collection through store.set("collection",collection);

@kfbishop
Copy link
Contributor

kfbishop commented Nov 8, 2013

@chrisfelix82 - On the init front. Couldn't we use 'features' test (has("worklight") to determine the WL version, and branch to a the proper init flow. I would actually put a stake in the ground and only support WL6 ++.

As far as auth goes, maybe two different init's; one for basic and one for encrypted (that requires creds).

Love the config settings.

@andrewferrier
Copy link
Author

Chris - my take - I basically agree with Karl. I think it would be very helpful to have the support in there - if Worklight breaks it again, worst case, we just take it out. I also agree that I also wouldn't even bother with WL < 6.0 - that's the current version now, and I think practically everyone is using it for new development.

The auth thing wasn't relevant for my recent PoC, so I didn't think about that, I have to admit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants