Skip to content

Commit 1a4eafc

Browse files
authored
Merge pull request #44 from podium-lib/podium-store-bridge-browser
docs: consolidate getting started and context
2 parents c8b2f06 + 8e57928 commit 1a4eafc

26 files changed

+1558
-1998
lines changed

.github/workflows/pull-request.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- source
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
18+
- name: Install dependencies
19+
run: npm install
20+
21+
- name: Build website
22+
run: npm run build

docs/api/assets.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const server = http.createServer(async (req, res) => {
9696

9797
server.listen(7100);
9898
```
99-
99+
100100
</TabItem>
101101
</Tabs>
102102

@@ -460,17 +460,17 @@ client side assets.
460460

461461
An `AssetJS` instance has the following properties:
462462

463-
| property | type | getter | setter | default | details |
464-
| -------------- | --------- | ------- | ------- | ------------ | -------------------------------------------------------------- |
465-
| value | `string` | &check; | | `''` | Relative or absolute URL to the CSS asset |
466-
| src | `string` | &check; | | `''` | Alias for the `value` property |
467-
| referrerpolicy | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
468-
| crossorigin | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
469-
| integrity | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
470-
| nomodule | `boolean` | &check; | &check; | `false` | Correlates to the same attribute on an HTML `<script>` element |
471-
| async | `boolean` | &check; | &check; | `false` | Correlates to the same attribute on an HTML `<script>` element |
472-
| defer | `boolean` | &check; | &check; | `false` | Correlates to the same attribute on an HTML `<script>` element |
473-
| type | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
463+
| property | type | getter | setter | default | details |
464+
| -------------- | --------- | ------- | ------- | ----------- | -------------------------------------------------------------- |
465+
| value | `string` | &check; | | `''` | Relative or absolute URL to the CSS asset |
466+
| src | `string` | &check; | | `''` | Alias for the `value` property |
467+
| referrerpolicy | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
468+
| crossorigin | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
469+
| integrity | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
470+
| nomodule | `boolean` | &check; | &check; | `false` | Correlates to the same attribute on an HTML `<script>` element |
471+
| async | `boolean` | &check; | &check; | `false` | Correlates to the same attribute on an HTML `<script>` element |
472+
| defer | `boolean` | &check; | &check; | `false` | Correlates to the same attribute on an HTML `<script>` element |
473+
| type | `string` | &check; | &check; | `undefined` | Correlates to the same attribute on an HTML `<script>` element |
474474

475475
## Methods
476476

docs/api/browser.md

+43-21
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,52 @@ id: browser
33
title: "@podium/browser"
44
---
55

6-
The `@podium/browser` package contains classes to provide browser based functionality when building Podium micro-frontends.
7-
8-
For now, this module only includes [MessageBus](#messagebus), but it is possible that it will include more features in the future.
6+
The `@podium/browser` module is a client-side library designed to simplify communication between a podlet and the layout, and between podlets.
97

108
## Installation
119

1210
```bash
13-
$ npm install @podium/browser
11+
npm install @podium/browser
1412
```
1513

16-
## MessageBus
14+
## Usage
15+
16+
In your podlet's client side JavaScript code, import the `MessageBus` class from the browser package and create a new instance of the class.
17+
18+
```js
19+
import { MessageBus } from "@podium/browser";
1720

18-
Cross podlet communication and message passing. For a information and examples on how and when to use this module, see [the guide](../podlet/podlet_to_podlet_communication)
21+
const messageBus = new MessageBus();
22+
```
23+
24+
### Publishing messages
25+
26+
To publish a message, call the `publish` method and pass a `channel`, a `topic` and any data you want subscribers to receive.
27+
28+
```js
29+
messageBus.publish("reminders", "newReminder", reminder);
30+
```
1931

20-
### Constructor
32+
### Subscribing to messages
2133

22-
Create a new MessageBus instance.
34+
To subscribe to messages on a particular channel and topic, call the `subscribe` method passing it the `channel`, `topic` and a callback function to be executed whenever an event occurs. Whenever the callback is executed it gets passed an `Event` object which has the properties `channel`, `topic` and `payload`.
35+
36+
```js
37+
messageBus.subscribe("reminders", "newReminder", (event) => {
38+
const reminder = event.payload;
39+
});
40+
```
41+
42+
## API
43+
44+
### MessageBus
45+
46+
Cross podlet communication and message passing.
2347

2448
```javascript
2549
const messageBus = new MessageBus();
2650
```
2751

28-
### API
29-
3052
#### .publish(channel, topic, payload)
3153

3254
Publish an event for a channel and topic combination. Returns the event object passed to subscribers.
@@ -42,9 +64,9 @@ This method takes the following arguments:
4264
Examples:
4365

4466
```javascript
45-
messageBus.publish('search', 'query', 'laptop');
67+
messageBus.publish("search", "query", "laptop");
4668

47-
messageBus.publish('auth', 'logout');
69+
messageBus.publish("auth", "logout");
4870
```
4971

5072
#### .subscribe(channel, topic, callback)
@@ -62,8 +84,8 @@ This method takes the following arguments:
6284
Example:
6385

6486
```javascript
65-
messageBus.subscribe('channel', 'topic', event => {
66-
console.log(event.payload);
87+
messageBus.subscribe("channel", "topic", (event) => {
88+
console.log(event.payload);
6789
});
6890
```
6991

@@ -83,12 +105,12 @@ Example:
83105

84106
```javascript
85107
function cb(event) {
86-
console.log(event.payload);
108+
console.log(event.payload);
87109
}
88110

89-
messageBus.subscribe('channel', 'topic', cb);
111+
messageBus.subscribe("channel", "topic", cb);
90112

91-
messageBus.unsubscribe('channel', 'topic', cb);
113+
messageBus.unsubscribe("channel", "topic", cb);
92114
```
93115

94116
#### .peek(channel, topic)
@@ -117,9 +139,9 @@ This method takes the following arguments:
117139
Example:
118140

119141
```javascript
120-
const events = messageBus.log('channel', 'topic');
142+
const events = messageBus.log("channel", "topic");
121143

122-
events.forEach(event => {
123-
console.log(event.payload);
144+
events.forEach((event) => {
145+
console.log(event.payload);
124146
});
125-
```
147+
```

docs/api/getting_started.md renamed to docs/api/http-framework-compatibility.mdx

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
---
2-
id: getting_started
3-
title: Getting Started
2+
title: HTTP Framework Compatibility
43
---
54

65
import Tabs from '@theme/Tabs';
76
import TabItem from '@theme/TabItem';
87

9-
Podium consists of two parts; podlets and layouts, each with its own matching module to be used for development.
10-
11-
### Podlets
12-
13-
When writing a server for serving page fragments (podlets), the [@podium/podlet module](api/podlet.md) should be used.
14-
15-
### Layouts
16-
17-
When writing a layout server in order to compose page fragments together, the [@podium/layout module](api/layout.md) should be used.
18-
19-
## HTTP Framework Compabillity
208

219
Podium is HTTP framework agnostic with first class support for [Express]. In
2210
practise this means that core Podium works with the standard [http.Server]

0 commit comments

Comments
 (0)