Skip to content

Commit

Permalink
Added an initialised event to the resources class.
Browse files Browse the repository at this point in the history
  • Loading branch information
parnham committed Oct 23, 2019
1 parent 84a9511 commit 57d5a52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ void main(List<String> args) async
var resources = ExampleResources();
var example = Example(resources);

resources.initialised.listen((_) {
print(example.Replace("a", "b"));
print(example.Ok);
print(example.Letters('a'));
});

await resources.Initialise(onError:
(m) => print('Missing or orphaned resources for module "$m"')
);

print(example.Replace("a", "b"));
print(example.Ok);
print(example.Letters('a'));
}

6 changes: 6 additions & 0 deletions lib/src/resources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import 'package:translatable/src/module.dart';

abstract class Resources
{
final _initialised = StreamController<void>.broadcast();
Stream<void> get initialised => _initialised.stream;

List<TranslatableModule> _modules = [];


void Register(TranslatableModule module)
{
this._modules.add(module);
Expand All @@ -24,6 +28,8 @@ abstract class Resources
onError(m.name);
}
}

this._initialised.add(null);
}

// Implement this to retrieve a map of strings for a given module based on how data
Expand Down

0 comments on commit 57d5a52

Please sign in to comment.