Permalink
Browse files

feature: ObservableProperty added

  • Loading branch information...
MikeMitterer committed Nov 2, 2018
1 parent 320c360 commit 6e0f4597f47f78ad19a6a1e38f306cb721950e25
Showing with 46 additions and 3 deletions.
  1. +6 −2 lib/m4d_core.dart
  2. +1 −1 lib/m4d_ioc.dart
  3. +24 −0 lib/m4d_utils.dart
  4. +15 −0 lib/utils/ConvertValue.dart
@@ -35,19 +35,23 @@ import 'package:validate/validate.dart';
import 'core/interfaces.dart';
import 'services.dart' as service;
import 'm4d_ioc.dart' as ioc;
import 'm4d_utils.dart';

export 'core/annotations.dart';
export 'core/interfaces.dart';

part "core/utils.dart";

part "core/MdlEventListener.dart";

part "core/MdlComponent.dart";
part "core/MdlComponentHandler.dart";
part "core/MdlConfig.dart";
part 'core/DomRenderer.dart';

part 'observable/ObservableList.dart';
part 'observable/ObservableProperty.dart';

part "core/utils.dart";

abstract class MdlDataConsumer {
void consume(final data);
}
@@ -55,7 +55,7 @@ class Service {
/// Very basic type-check (Instance, Function, Json)
final ServiceType type;

Service(this.name, this.type);
const Service(this.name, this.type);

@override
bool operator ==(Object other) =>
@@ -23,9 +23,33 @@
*/
library m4d_utils;

import 'dart:async';

// import 'package:logging/logging.dart';
import 'package:validate/validate.dart';

part 'utils/StringToFunction.dart';
part "utils/ConvertValue.dart";

/// Waits until [test] returns true
///
/// Can be used to test if an element is already in the DOM
Future<int> waitUntil(bool test(),{
final int maxIterations: 100,
final Duration step: const Duration(milliseconds: 10) }) async {

int iterations = 0;
for(;iterations < maxIterations;iterations++) {
await Future.delayed(step);
if(test()) {
break;
}
}
if(iterations >= maxIterations) {
throw TimeoutException(
"Condition not reached within ${iterations * step.inMilliseconds}ms");
}
return iterations;
}


@@ -40,6 +40,10 @@ class ConvertValue {
}

static int toInt(final value) {
if(value == null) {
return 0;
}

if(value is int) {
return value;
}
@@ -51,6 +55,10 @@ class ConvertValue {
}

static double toDouble(final value) {
if(value == null) {
return 0.0;
}

if(value is double) {
return value;
}
@@ -61,6 +69,13 @@ class ConvertValue {
return num.parse(stringvalue).toDouble();
}

static String toStringValue(final value) {
if(value == null) {
return "";
}
return value.toString();
}

/// Removes ' and " around the give value
/// and converts [value] to String
static String toSanitizeString(final value) {

0 comments on commit 6e0f459

Please sign in to comment.