-
-
+
+
-
-
+
+
+ ID
+ Name
+
+ Delete
+
+
+ {#each thingsList as t}
+
+
+ {t.ID}
+
+
+
+ {t.Name}
+
+
+
+
+
+ {/each}
+
+
diff --git a/frontend/wailsjs/go/models.ts b/frontend/wailsjs/go/models.ts
new file mode 100755
index 0000000..e590fe2
--- /dev/null
+++ b/frontend/wailsjs/go/models.ts
@@ -0,0 +1,19 @@
+export namespace things {
+
+ export class Thing {
+ ID: number;
+ Name: string;
+
+ static createFrom(source: any = {}) {
+ return new Thing(source);
+ }
+
+ constructor(source: any = {}) {
+ if ('string' === typeof source) source = JSON.parse(source);
+ this.ID = source["ID"];
+ this.Name = source["Name"];
+ }
+ }
+
+}
+
diff --git a/frontend/wailsjs/go/things/Service.d.ts b/frontend/wailsjs/go/things/Service.d.ts
new file mode 100755
index 0000000..0f9aab6
--- /dev/null
+++ b/frontend/wailsjs/go/things/Service.d.ts
@@ -0,0 +1,9 @@
+// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
+// This file is automatically generated. DO NOT EDIT
+import {things} from '../models';
+
+export function DeleteThing(arg1:number):Promise
;
+
+export function GetThings():Promise>;
+
+export function NewThing(arg1:string):Promise;
diff --git a/frontend/wailsjs/go/things/Service.js b/frontend/wailsjs/go/things/Service.js
new file mode 100755
index 0000000..1d5ee94
--- /dev/null
+++ b/frontend/wailsjs/go/things/Service.js
@@ -0,0 +1,15 @@
+// @ts-check
+// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
+// This file is automatically generated. DO NOT EDIT
+
+export function DeleteThing(arg1) {
+ return window['go']['things']['Service']['DeleteThing'](arg1);
+}
+
+export function GetThings() {
+ return window['go']['things']['Service']['GetThings']();
+}
+
+export function NewThing(arg1) {
+ return window['go']['things']['Service']['NewThing'](arg1);
+}
diff --git a/main.go b/main.go
index 60b1d34..b744f26 100644
--- a/main.go
+++ b/main.go
@@ -2,6 +2,7 @@ package main
import (
"embed"
+ "wails-svelte-tailwind-ts/things"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
@@ -14,6 +15,7 @@ var assets embed.FS
func main() {
// Create an instance of the app structure
app := NewApp()
+ things := things.NewThingsService()
// Create application with options
err := wails.Run(&options.App{
@@ -27,6 +29,7 @@ func main() {
OnStartup: app.startup,
Bind: []interface{}{
app,
+ things,
},
})
diff --git a/things/resource.go b/things/resource.go
new file mode 100644
index 0000000..6bd18ba
--- /dev/null
+++ b/things/resource.go
@@ -0,0 +1,43 @@
+package things
+
+import "slices"
+
+type Thing struct {
+ ID int
+ Name string
+}
+
+type Service struct {
+ things map[int]Thing
+ maxID int
+}
+
+func NewThingsService() *Service {
+ return &Service{
+ things: make(map[int]Thing),
+ }
+}
+
+func (s *Service) NewThing(name string) {
+ s.maxID++
+ s.things[s.maxID] = Thing{
+ Name: name,
+ ID: s.maxID,
+ }
+
+ print(name)
+}
+
+func (s *Service) GetThings() []Thing {
+ things := make([]Thing, 0, len(s.things))
+ for _, t := range s.things {
+ things = append(things, t)
+ }
+ slices.SortFunc(things, func(a, b Thing) int { return a.ID - b.ID })
+ return things
+}
+
+func (s *Service) DeleteThing(id int) {
+ delete(s.things, id)
+
+}