Skip to content

Commit 17d376b

Browse files
more updates
1 parent f94c356 commit 17d376b

File tree

4 files changed

+22
-26
lines changed

4 files changed

+22
-26
lines changed

Magic.IndexedDb/IndexDbManager.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -572,18 +572,5 @@ internal async Task<T> CallJsAsync<T>(string functionName, CancellationToken tok
572572

573573
return await magicJsInvoke.MagicStreamJsAsync<T>(functionName, token, args) ?? default;
574574
}
575-
576-
577-
// Synchronous alternatives
578-
internal void CallJs(string functionName, CancellationToken token, params ITypedArgument[] args)
579-
{
580-
CallJsAsync(functionName, token, args).GetAwaiter().GetResult();
581-
}
582-
583-
internal T CallJs<T>(string functionName, CancellationToken token, params ITypedArgument[] args)
584-
{
585-
return CallJsAsync<T>(functionName, token, args).GetAwaiter().GetResult();
586-
}
587-
588575
}
589576
}

Magic.IndexedDb/Magic.IndexedDb.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
<ItemGroup>
4545
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.11" />
46+
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
4647
</ItemGroup>
4748

4849
</Project>

Magic.IndexedDb/Models/MagicQuery.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ public async Task<IEnumerable<T>> Execute()
9999
return await Manager.WhereV2Async<T>(SchemaName, JsonQueries, this, default) ?? Enumerable.Empty<T>();
100100
}
101101

102-
//.GetAwaiter().GetResult()
102+
/* public async Task<IEnumerable<T>> AsAsyncEnumerable()
103+
{
104+
return await Manager.WhereV2Async<T>(SchemaName, JsonQueries, this, default) ?? Enumerable.Empty<T>();
105+
}*/
103106

104107
/// <summary>
105108
/// safe to use, but emulates an IAsync until future implementation
@@ -120,27 +123,26 @@ public async IAsyncEnumerable<T> AsAsyncEnumerable([EnumeratorCancellation] Canc
120123
}
121124

122125

126+
123127
public async Task<List<T>> ToListAsync()
124128
{
125129
return (await Manager.WhereV2Async<T>(SchemaName, JsonQueries, this, default))?.ToList() ?? new List<T>();
126130
}
127131

128-
public IEnumerable<T> AsEnumerable()
132+
/* public IEnumerable<T> AsEnumerable()
129133
{
130134
return Manager.WhereV2Async<T>(SchemaName, JsonQueries, this, default)
131-
.GetAwaiter()
132-
.GetResult()
133-
?? Enumerable.Empty<T>();
135+
.ToBlockingEnumerable(); // ✅ Safe synchronous conversion
134136
}
135137
136138
public List<T> ToList()
137139
{
138140
return Manager.WhereV2Async<T>(SchemaName, JsonQueries, this, default)
139-
.GetAwaiter()
140-
.GetResult()
141-
?.ToList()
142-
?? new List<T>();
143-
}
141+
.ToBlockingEnumerable()
142+
.ToList();
143+
}*/
144+
145+
144146

145147
public async Task<int> Count()
146148
{

TestWasm/Pages/Home.razor

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,18 @@
127127

128128
allPeople = (await manager.GetAllAsync<Person>()).ToList();
129129

130-
WhereExample = await manager.Where<Person>(x => x.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase)
130+
131+
// WhereExample = await (manager.Where<Person>(x => x.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase)
132+
// || x.Name.StartsWith("l", StringComparison.OrdinalIgnoreCase)
133+
// || x.Name.StartsWith("j", StringComparison.OrdinalIgnoreCase) && x._Age > 35
134+
// || x.Name.Contains("bo", StringComparison.OrdinalIgnoreCase)
135+
// ).OrderBy(x => x._Id).Skip(1).AsAsyncEnumerable()).ToListAsync();
136+
137+
WhereExample = (manager.Where<Person>(x => x.Name.StartsWith("c", StringComparison.OrdinalIgnoreCase)
131138
|| x.Name.StartsWith("l", StringComparison.OrdinalIgnoreCase)
132139
|| x.Name.StartsWith("j", StringComparison.OrdinalIgnoreCase) && x._Age > 35
133140
|| x.Name.Contains("bo", StringComparison.OrdinalIgnoreCase)
134-
).OrderBy(x => x._Id).Skip(1).ToListAsync();
135-
141+
).OrderBy(x => x._Id).Skip(1).ToList());
136142

137143

138144
/*

0 commit comments

Comments
 (0)