Sporran is a PouchDB alike implementation for Dart.
It uses Lawndart(browser local storage client) and Wilt(browser CouchDB client) to allow browser based CouchDB users to transition between online and offline modes and carry on working normally.
When the browser is online Sporran acts just like Wilt, i.e is a CouchDB client, but all database transactions are reflected into local storage. If the browser goes offline Sporran switches to using local storage only, when the browser comes back online the local database is synced up with CouchDB, all transparent to the user.
The CouchDB change notification interface is also used to keep Sporran in sync with any 3rd party changes to your CouchDB database.
Please read the documents under the doc folder for usage information, the API is also under this folder and is available here
Queries you can direct to me at steve.hamblett@linux.com or raise an issue here.
Formatting for pana
Update description for pana
Update to dart 2.0, issue 15
Update to new Wilt + JsonObjectLite, remove analysis errors
Updates ready for Dart 2, remove the completion interface.
Updates for issues 7, 5, 6, 8 and 4 Note that issue 4 changes how Sporran is constructed and is thus breaking.
Updates for DartV1.5.3, all tests running
Issues 1 and 2, Sporran now has a futures based API
Initial release
example/sporran.dart
/*
* Package : Sporran
* Author : S. Hamblett <steve.hamblett@linux.com>
* Date : 17/09/2018
* Copyright : S.Hamblett
*/
import 'package:sporran/sporran.dart';
import 'package:json_object_lite/json_object_lite.dart';
import '../test/lib/sporran_test_config.dart';
/// An example of sporran initialisation and usage, see the test scenarios for more detailed
/// use cases.
void main() async {
// Initialise Sporran
final SporranInitialiser initialiser = new SporranInitialiser();
initialiser.dbName = databaseName;
initialiser.hostname = hostName;
initialiser.manualNotificationControl = true;
initialiser.port = port;
initialiser.scheme = scheme;
initialiser.username = userName;
initialiser.password = userPassword;
initialiser.preserveLocal = false;
// Create the client
final Sporran sporran = new Sporran(initialiser);
sporran.autoSync = false;
await sporran.onReady.first;
/// Put a document
final dynamic onlineDoc = new JsonObjectLite();
final String docIdPutOnline = "putOnlineg3";
onlineDoc.name = "Online";
await sporran.put(docIdPutOnline, onlineDoc);
/// Get it
sporran.get(docIdPutOnline)
..then((res) {
final dynamic payload = new JsonObjectLite.fromJsonString(res.payload);
print(payload.payload.name);
});
/// Get it offline
sporran.online = false;
sporran.get(docIdPutOnline)
..then((res) {
final dynamic payload = new JsonObjectLite.fromJsonString(res.payload);
print(payload.payload.name);
});
}
Add this to your package's pubspec.yaml file:
dependencies:
sporran: ^4.0.2
You can install packages from the command line:
with pub:
$ pub get
Alternatively, your editor might support pub get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:sporran/sporran.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
4.0.2 | Sep 25, 2018 |
|
|
4.0.1 | Sep 25, 2018 |
|
|
4.0.0 | Sep 17, 2018 |
|
|
3.1.0 | Dec 15, 2017 |
|
|
3.0.0 | Sep 12, 2017 |
|
|
2.1.0 | Sep 17, 2014 |
|
|
2.0.0 | Mar 13, 2014 |
|
|
1.0.0 | Mar 3, 2014 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
48
|
Health:
Code health derived from static analysis.
[more]
|
90
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
71
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: web
Primary library:
package:sporran/sporran.dart
with components:html
.
Fix lib/src/Sporran.dart
. (-6.31 points)
Analysis of lib/src/Sporran.dart
reported 13 hints, including:
line 194 col 51: Don't explicitly initialize variables to null.
line 260 col 26: Don't explicitly initialize variables to null.
line 333 col 29: Don't explicitly initialize variables to null.
line 784 col 24: Use =
to separate a named parameter from its default value.
line 785 col 7: Don't explicitly initialize variables to null.
Fix lib/src/SporranDatabase.dart
. (-4.41 points)
Analysis of lib/src/SporranDatabase.dart
reported 9 hints, including:
line 33 col 7: Don't explicitly initialize variables to null.
line 34 col 7: Don't explicitly initialize variables to null.
line 43 col 34: Future
results in async
function bodies must be await
ed or marked unawaited
using package:pedantic
.
line 55 col 10: Don't explicitly initialize variables to null.
line 59 col 10: Don't explicitly initialize variables to null.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev <3.0.0 | ||
json_object_lite | ^2.0.0 | 2.0.0 | |
wilt | >=4.0.0 <=5.0.0 | 4.0.1 | |
Transitive dependencies | |||
async | 2.0.8 | ||
charcode | 1.1.2 | ||
collection | 1.14.11 | ||
convert | 2.1.1 | ||
crypto | 2.0.6 | ||
http | 0.11.3+17 | 0.12.0+1 | |
http_parser | 3.1.3 | ||
meta | 1.1.7 | ||
path | 1.6.2 | ||
source_span | 1.5.4 | ||
string_scanner | 1.0.4 | ||
term_glyph | 1.1.0 | ||
typed_data | 1.1.6 | ||
Dev dependencies | |||
build_runner | ^0.10.0 | ||
build_test | ^0.10.2 | ||
build_web_compilers | ^0.4.0 | ||
coverage | ^0.12.2 | ||
dart_style | ^1.1.3 | ||
dartdoc | ^0.20.3 | ||
test | ^1.3.0 |