Skip to content

Commit 2989afd

Browse files
committed
Add workspace control buttons and align text style
New Pause, Resume, and Step buttons have been added to the Wolder Interactive Web project for workspace control. The text in the 'main' selector of MainLayout.razor.css was aligned to the center. Workflow event handling improvements were also made in the Web and Core projects.
1 parent fb19c3c commit 2989afd

File tree

8 files changed

+30
-3
lines changed

8 files changed

+30
-3
lines changed

src/Wolder.Core/Workspace/Events/WorkspaceStateDelegateDispatcher.cs

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public WorkspaceStateEventDispatcher()
1212
WorkspaceInitializedAsync = async () =>
1313
await Task.WhenAll(Delegates.Select(d =>
1414
d.WorkspaceInitializedAsync())),
15+
WorkspaceRunEndAsync = async () =>
16+
await Task.WhenAll(Delegates.Select(d =>
17+
d.WorkspaceRunEndAsync())),
1518
InvocationBeginAsync = async (c) =>
1619
await Task.WhenAll(Delegates.Select(d =>
1720
d.InvocationBeginAsync(c))),

src/Wolder.Core/Workspace/Events/WorkspaceStateEvents.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public class WorkspaceStateEvents
44
{
55
public Func<Task> WorkspaceInitializedAsync { get; set; } = () => Task.CompletedTask;
6+
public Func<Task> WorkspaceRunEndAsync { get; set; } = () => Task.CompletedTask;
67
public Func<InvocationBeginContext, Task> InvocationBeginAsync { get; set; } = (c) => Task.CompletedTask;
78
public Func<InvocationEndContext, Task> InvocationEndAsync { get; set; } = (c) => Task.CompletedTask;
89
}

src/Wolder.Core/Workspace/GeneratorWorkspaceBuilder.cs

+1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ public async Task BuildWorkspaceAndRunAsync<TRootAction>(string rootPath)
5151
await EventDispatcher.Events.WorkspaceInitializedAsync();
5252
var invokeRootAction = serviceProvider.GetRequiredService<IInvoke>();
5353
await invokeRootAction.InvokeVoidAsync<TRootAction>();
54+
await EventDispatcher.Events.WorkspaceRunEndAsync();
5455
}
5556
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
@page "/"
2+
@using Wolder.Interactive.Web.Services
3+
4+
@inject WorkspaceStateManager WorkspaceStateManager;
5+
6+
@rendermode InteractiveServer
7+
28
<h3>Wolder Interactive</h3>
39

10+
<div>
11+
<button @onclick="WorkspaceStateManager.Pause">Pause</button>
12+
<button @onclick="WorkspaceStateManager.Resume">Resume</button>
13+
<button @onclick="WorkspaceStateManager.Step">Step</button>
14+
</div>
15+
416
@code {
517

618
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

22
main {
33
font-family: monospace;
4+
text-align: center;
45
}

src/Wolder.Interactive.Web/Services/WorkspaceStateManager.cs

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public WorkspaceStateManager()
1212
Events = new()
1313
{
1414
WorkspaceInitializedAsync = WorkspaceInitializedAsync,
15+
WorkspaceRunEndAsync = WorkspaceRunEndAsync,
1516
InvocationBeginAsync = InvocationBeginAsync,
1617
InvocationEndAsync = InvocationEndAsync,
1718
};
@@ -50,6 +51,12 @@ private async Task InvocationBeginAsync(InvocationBeginContext c)
5051
InvocationBegin?.Invoke(new InvocationDetail(c.Invokable.GetType().Name));
5152
await _proceedWhenUnpaused.Task;
5253
}
54+
55+
private async Task WorkspaceRunEndAsync()
56+
{
57+
Pause();
58+
await _proceedWhenUnpaused.Task;
59+
}
5360

5461
private Task InvocationEndAsync(InvocationEndContext c)
5562
{

src/Wolder.Interactive.Web/SetupExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static GeneratorWorkspaceBuilder AddInteractiveWebServer(this GeneratorWo
99
{
1010
var server = new WorkspaceInteractiveWebHost();
1111
builder.Services.AddSingleton(server);
12-
builder.EventDispatcher.Delegates.Add(server.WorkspaceStateNotifications.Events);
12+
builder.EventDispatcher.Delegates.Add(server.WorkspaceStateManager.Events);
1313
return builder;
1414
}
1515
}

src/Wolder.Interactive.Web/WorkspaceInteractiveWebHost.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ public class WorkspaceInteractiveWebHost
1111

1212
public WorkspaceInteractiveWebHost()
1313
{
14-
WorkspaceStateNotifications.WorkspaceInitialized += () =>
14+
WorkspaceStateManager.WorkspaceInitialized += () =>
1515
{
1616
_serverInitializeTask = StartAsync();
1717
};
1818
}
1919

20-
public WorkspaceStateManager WorkspaceStateNotifications { get; } = new();
20+
public WorkspaceStateManager WorkspaceStateManager { get; } = new();
2121

2222
private async Task StartAsync()
2323
{
@@ -32,6 +32,8 @@ private async Task StartAsync()
3232
ApplicationName = "Wolder.Interactive.Web"
3333
});
3434

35+
webBuilder.Services.AddSingleton(WorkspaceStateManager);
36+
3537
// Add services to the container.
3638
webBuilder.Services.AddRazorComponents()
3739
.AddInteractiveServerComponents();

0 commit comments

Comments
 (0)