-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* sdk/dotnet-code_snippets - csharp snippets: multiple_events and setup * sdk/dotnet-code_snippets - setup updated to be more terse * Update multiple_events.csharpsnippet * Update README.md --------- Co-authored-by: Greg Holden <[email protected]>
- Loading branch information
Showing
3 changed files
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
code/go/site/static/code_snippets/getting_started/multiple_events.csharpsnippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sse.MergeFragments(@"<div id=""question"">...</div>"); | ||
sse.MergeFragments(@"<div id=""instructions"">...</div>"); | ||
sse.MergeSignals("{answer: '...'}"); | ||
sse.MergeSignals("{prize: '...'}"); |
13 changes: 13 additions & 0 deletions
13
code/go/site/static/code_snippets/getting_started/setup.csharpsnippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using StarFederation.Datastar.DependencyInjection; | ||
|
||
// add as a service | ||
builder.Services.AddDatastar(); | ||
|
||
app.MapGet("/", async (IServerSentEventGenerator sse) => | ||
{ | ||
// Merges HTML fragments into the DOM. | ||
await sse.MergeFragments(@"<div id=""question"">What do you put in a toaster?</div>"); | ||
|
||
// Merges signals into the store. | ||
await sse.MergeSignals("{response: '', answer: 'bread'}"); | ||
}); |