Skip to content

Commit

Permalink
Reworked the resource initialisation and loading functions so that mo…
Browse files Browse the repository at this point in the history
…dules

can be requested simultaneously.
  • Loading branch information
parnham committed Aug 19, 2020
1 parent a39959c commit 9ad6814
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions lib/src/resources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ abstract class Resources
this._modules.add(module);
}

// Future<List<Language>> Languages();

Future Initialise({ void onError(String) }) async
{
List<Future<TranslatableModule>> loading = [];

// Retrieve values for current language and check if any expected values
// are missing or unexpected values found
for (var m in this._modules)
{
await LoadModule(m, null);
loading.add(LoadModule(m, null));
}

for (var l in loading)
{
var m = await l;

if ((m.missing || m.orphaned) && onError != null)
{
Expand Down Expand Up @@ -65,13 +72,19 @@ abstract class Resources
Future<List<TranslatableModule>> Load(String language) async
{
List<TranslatableModule> result = [];
List<Future<TranslatableModule>> loading = [];

for (var m in this._modules)
{
var module = await this.LoadModule(
loading.add(this.LoadModule(
TranslatableModule.base(m.name, Map.from(m.values)),
language
);
));
}

for (var l in loading)
{
var module = await l;

module.originals = Map.from(module.values);
result.add(module);
Expand All @@ -80,5 +93,4 @@ abstract class Resources
return result;
}


}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: translatable
version: 1.1.0
version: 1.1.1
author: Dan Parnham <[email protected]>
homepage: https://github.com/emergent-design/translatable
description: >-
Expand Down

0 comments on commit 9ad6814

Please sign in to comment.