1 decade ago by Jesse
I packaged up Lawnchair as a plugin for ImpactJS. I made a few small changes:
- Extended from Impact's ig.Class, doesn't need jQuery. This makes it possible to have a "MyStore" class that just extends from ig.Lawnchair, but passes the store settings to "parent" in its "init" method. This methodology makes the code much cleaner because you only have to configure Lawnchair in one spot, and you can stick your storage methods on that class, and not have them all over the place like in the Game class.
- Lives in the "ig" namespace: "ig.Lawnchair"
- Uses "staticInstantiate" to return the same store every time an ig.Lawnchair is created, just like ig.Image objects use the image's path to return the same ig.Image.
- Accepts a store name as the first parameter as a 'string' object in the constructor, as well as the original { name: 'example' } so you can do:
- Has 3 built-in adapters: dom, memory, webkit-sqlite which are all pasted into the main plugin for less HTTP requests to get Lawnchair functionality.
- You should just need one request for the working library, and only more if you want the optional Lawnchair plugins
- Can pass in "adapterName" as a property of an object that you pass into the constructor if you prefer a certain adapter to be used everytime, but this isn't needed as you'll be given one automatically by Lawnchair
- Does not require a callback as the second constructor parameter, will use "callbackDefault" member of ig.Lawnchair object
- Supports Lawnchair plugins, although you'll have to change the reference of "Lawnchair" to ig.Lawnchair. You don't really need Lawnchair plugins to get and save data, they just make it easier to do so with syntax enhancements. You should just be good with the "impact-plugin" module.
Download it from GitHub:
https://github.com/jmo84/Lawnchair-plugin-for-ImpactJS/
Official Lawnchair site:
http://westcoastlogic.com/lawnchair/
- Extended from Impact's ig.Class, doesn't need jQuery. This makes it possible to have a "MyStore" class that just extends from ig.Lawnchair, but passes the store settings to "parent" in its "init" method. This methodology makes the code much cleaner because you only have to configure Lawnchair in one spot, and you can stick your storage methods on that class, and not have them all over the place like in the Game class.
- Lives in the "ig" namespace: "ig.Lawnchair"
- Uses "staticInstantiate" to return the same store every time an ig.Lawnchair is created, just like ig.Image objects use the image's path to return the same ig.Image.
- Accepts a store name as the first parameter as a 'string' object in the constructor, as well as the original { name: 'example' } so you can do:
var store = new ig.Lawnchair('teststore', function() { console.log('teststore is ready'); } );
- Has 3 built-in adapters: dom, memory, webkit-sqlite which are all pasted into the main plugin for less HTTP requests to get Lawnchair functionality.
- You should just need one request for the working library, and only more if you want the optional Lawnchair plugins
- Can pass in "adapterName" as a property of an object that you pass into the constructor if you prefer a certain adapter to be used everytime, but this isn't needed as you'll be given one automatically by Lawnchair
- Does not require a callback as the second constructor parameter, will use "callbackDefault" member of ig.Lawnchair object
- Supports Lawnchair plugins, although you'll have to change the reference of "Lawnchair" to ig.Lawnchair. You don't really need Lawnchair plugins to get and save data, they just make it easier to do so with syntax enhancements. You should just be good with the "impact-plugin" module.
Download it from GitHub:
https://github.com/jmo84/Lawnchair-plugin-for-ImpactJS/
Official Lawnchair site:
http://westcoastlogic.com/lawnchair/