Skip to content

Commit

Permalink
add example that uses named param from route
Browse files Browse the repository at this point in the history
  • Loading branch information
floodfx committed Oct 2, 2022
1 parent b7ca83f commit cc82780
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/examples/dist/liveviewjs-examples.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ declare const decarbLiveView: liveviewjs.LiveView<{
*/
declare const xkcdLiveView: liveviewjs.LiveView<liveviewjs.AnyLiveContext, liveviewjs.AnyLiveEvent, liveviewjs.AnyLiveInfo>;

declare const helloNameLiveView: liveviewjs.LiveView<liveviewjs.AnyLiveContext, liveviewjs.AnyLiveEvent, liveviewjs.AnyLiveInfo>;

declare const helloToggleEmojiLiveView: liveviewjs.LiveView<liveviewjs.AnyLiveContext, liveviewjs.AnyLiveEvent, liveviewjs.AnyLiveInfo>;

declare type MyContext = {
Expand Down Expand Up @@ -330,4 +332,4 @@ interface RouteDetails {
}
declare const routeDetails: RouteDetails[];

export { FootprintData, FootprintUpdateInfo, PaginateOptions, RouteDetails, SortOptions, autocompleteLiveView, booksLiveView, counterLiveView, dashboardLiveView, decarbLiveView, helloToggleEmojiLiveView, jsCmdsLiveView, paginateLiveView, photosLiveView, printLiveView, routeDetails, rtCounterLiveView, searchLiveView, serversLiveView, sortLiveView, volumeLiveView, volunteerLiveView, xkcdLiveView };
export { FootprintData, FootprintUpdateInfo, PaginateOptions, RouteDetails, SortOptions, autocompleteLiveView, booksLiveView, counterLiveView, dashboardLiveView, decarbLiveView, helloNameLiveView, helloToggleEmojiLiveView, jsCmdsLiveView, paginateLiveView, photosLiveView, printLiveView, routeDetails, rtCounterLiveView, searchLiveView, serversLiveView, sortLiveView, volumeLiveView, volunteerLiveView, xkcdLiveView };
12 changes: 12 additions & 0 deletions packages/examples/dist/liveviewjs-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,17 @@ function today(path) {
});
}

const helloNameLiveView = liveviewjs.createLiveView({
mount: (socket, _, params) => {
var _a;
socket.assign({ name: (_a = params.name) !== null && _a !== void 0 ? _a : "World" });
},
render: (context) => {
const { name } = context;
return liveviewjs.html `👋 ${name}! `;
},
});

const helloToggleEmojiLiveView = liveviewjs.createLiveView({
mount: (socket) => {
socket.assign({ useEmoji: false });
Expand Down Expand Up @@ -3130,6 +3141,7 @@ exports.booksLiveView = booksLiveView;
exports.counterLiveView = counterLiveView;
exports.dashboardLiveView = dashboardLiveView;
exports.decarbLiveView = decarbLiveView;
exports.helloNameLiveView = helloNameLiveView;
exports.helloToggleEmojiLiveView = helloToggleEmojiLiveView;
exports.jsCmdsLiveView = jsCmdsLiveView;
exports.paginateLiveView = paginateLiveView;
Expand Down
13 changes: 12 additions & 1 deletion packages/examples/dist/liveviewjs-examples.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,17 @@ function today(path) {
});
}

const helloNameLiveView = createLiveView({
mount: (socket, _, params) => {
var _a;
socket.assign({ name: (_a = params.name) !== null && _a !== void 0 ? _a : "World" });
},
render: (context) => {
const { name } = context;
return html `👋 ${name}! `;
},
});

const helloToggleEmojiLiveView = createLiveView({
mount: (socket) => {
socket.assign({ useEmoji: false });
Expand Down Expand Up @@ -3123,4 +3134,4 @@ const routeDetails = [
},
];

export { autocompleteLiveView, booksLiveView, counterLiveView, dashboardLiveView, decarbLiveView, helloToggleEmojiLiveView, jsCmdsLiveView, paginateLiveView, photosLiveView, printLiveView, routeDetails, rtCounterLiveView, searchLiveView, serversLiveView, sortLiveView, volumeLiveView, volunteerLiveView, xkcdLiveView };
export { autocompleteLiveView, booksLiveView, counterLiveView, dashboardLiveView, decarbLiveView, helloNameLiveView, helloToggleEmojiLiveView, jsCmdsLiveView, paginateLiveView, photosLiveView, printLiveView, routeDetails, rtCounterLiveView, searchLiveView, serversLiveView, sortLiveView, volumeLiveView, volunteerLiveView, xkcdLiveView };
11 changes: 11 additions & 0 deletions packages/examples/src/liveviews/hello/helloName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createLiveView, html } from "liveviewjs";

export const helloNameLiveView = createLiveView({
mount: (socket, _, params) => {
socket.assign({ name: params.name ?? "World" });
},
render: (context) => {
const { name } = context;
return html`👋 ${name}! `;
},
});
1 change: 1 addition & 0 deletions packages/examples/src/rollupEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./liveviews/counter/realtime";
export * from "./liveviews/dashboard";
export * from "./liveviews/decarbonize";
export * from "./liveviews/fetch";
export * from "./liveviews/hello/helloName";
export * from "./liveviews/hello/helloToggleEmoji";
export * from "./liveviews/jsCommands";
export * from "./liveviews/liveSearch";
Expand Down

0 comments on commit cc82780

Please sign in to comment.