Skip to content
Permalink
Browse files

feature: SimpleDataStoreMixin added

  • Loading branch information...
MikeMitterer committed Nov 21, 2018
1 parent cc9f4a9 commit 13e0350faee0ba5c9a48e178f1149b0e5ddc844c
Showing with 53 additions and 19 deletions.
  1. +31 −0 CHANGELOG.md
  2. +21 −18 lib/m4d_directive.dart
  3. +1 −1 samples/m4d_model/web/main.dart
@@ -0,0 +1,31 @@
# Change Log for m4d_directive
Material Design 4 Dart - Directives

## [Unreleased](http://github.com/mikemitterer/m4d_directive/compare/v0.1...HEAD)

### Feature
* Added some init-vars for SimpleValueStore [5e2bcff](https://github.com/mikemitterer/m4d_directive/commit/5e2bcff572bc12f42540de8b81f9009e0368300a)

### Bugs
* Formatter was not propperly set in DefaultSimpleDataStore [f0d20a5](https://github.com/mikemitterer/m4d_directive/commit/f0d20a5c4726c8a53ba6c502f2b251f632c9cd7e)

### Docs
* Better log-output for DefaultSimpleDataStore [acde27d](https://github.com/mikemitterer/m4d_directive/commit/acde27d842593a22d228edce09f87af3ea41d2f4)

## [v0.1](http://github.com/mikemitterer/m4d_directive/compare/v0.1) - 2018-11-02

### Feature
* Data binding / MaterialModel implemented and works [58fd197](https://github.com/mikemitterer/m4d_directive/commit/58fd197aecbaf05650e8d9f33ef80d6326d61689)

### Bugs
* Wrong pubspec for examples [7c0f0ad](https://github.com/mikemitterer/m4d_directive/commit/7c0f0ad993e28eb8e52cf357598f8de946c772f3)

### Docs
* Autogen examples with Jenkins + cmdline [0a790b0](https://github.com/mikemitterer/m4d_directive/commit/0a790b0eed3fc3f9374b17a2a4832617ee0b9af0)
* m4d_class-sample and m4d_attribute-sample work with SimpleValueStore [7788016](https://github.com/mikemitterer/m4d_directive/commit/7788016c6e4db987207d44b052d4ff53f9febea8)

### Test
* MaterialAttribute_test tested against wrong attribute [0f9c6ec](https://github.com/mikemitterer/m4d_directive/commit/0f9c6ec9d3823f18195d24a4ecede19a033148d6)


This CHANGELOG.md was generated with [**Changelog for Dart**](https://pub.dartlang.org/packages/changelog)
@@ -55,21 +55,8 @@ part "directive/components/model/ModelObserverFactory.dart";

part "directive/utils.dart";

/// Default implementation for SimpleValueStore
///
/// Overwrite it like this:
/// class MyDataStore extends Emitter implements SimpleValueStore {
/// ...
/// }
///
/// main() {
/// ioc.IOCContainer().bind(service.SimpleDataStore).to(MyDataStore());
/// }
///
/// void somewhereInYourCode() {
/// final store = ioc.IOCContainer().resolve(service.SimpleDataStore).as<MyDataStore>();
/// }
class DefaultSimpleDataStore extends Emitter implements SimpleValueStore {
/// Mixin for simplifying the integration into your own App-Store
abstract class SimpleDataStoreMixin implements SimpleValueStore {
final Logger _logger = new Logger('m4d_directive.DefaultSimpleDataStore');

@protected
@@ -88,7 +75,7 @@ class DefaultSimpleDataStore extends Emitter implements SimpleValueStore {

@override
ObservableProperty<T> prop<T>(final String varname,{
final T initWith = null, final FormatObservedValue<T> formatter = null }) {
final T initWith = null, final FormatObservedValue<T> formatter = null }) {

if(!bindings.containsKey(varname)) {
bindings[varname] = ObservableProperty<T>(initWith, formatter: formatter);
@@ -97,15 +84,31 @@ class DefaultSimpleDataStore extends Emitter implements SimpleValueStore {
emitChange();
});
}

if(formatter != null) {
bindings[varname].onFormat(formatter);
}

return bindings[varname];
}
}

/// Default implementation for SimpleValueStore
///
/// Overwrite it like this:
/// class MyDataStore extends Emitter implements SimpleValueStore {
/// ...
/// }
///
/// main() {
/// ioc.IOCContainer().bind(service.SimpleDataStore).to(MyDataStore());
/// }
///
/// void somewhereInYourCode() {
/// final store = ioc.IOCContainer().resolve(service.SimpleDataStore).as<MyDataStore>();
/// }
class DefaultSimpleDataStore extends Emitter with SimpleDataStoreMixin {}

void registerMdlDirectiveComponents() {
registerMaterialAttribute();
registerMaterialClass();
@@ -8,7 +8,7 @@ main() async {
CoreComponentsModule(), DirectivesModule()
]);

final app = await componentHandler().run();
final app = await componentHandler().upgrade();
app.run();
}

0 comments on commit 13e0350

Please sign in to comment.
You can’t perform that action at this time.