Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/levyks/tepkijs


https://github.com/levyks/tepkijs

Last synced: 8 days ago
JSON representation

Awesome Lists containing this project

README

        

# Tepki.JS

## Work in Progress

Remote stores powered by Socket.IO with a Vue/Vuex like syntax in the backend.

[Client repo](https://github.com/Levyks/tepkijs-client)

Server:
```ts
import { createStore } from 'tepkijs';
import { Server } from 'socket.io';

const io = new Server(5000, {
cors: {
origin: '*',
}
});

const store = createStore({
io, name: 'room-01',
data: {
messages: [],
_somethingPrivate: {}
},
methods: {
addMessage(message) {
this.messages.push(message);
}
}
});
```

Client (Svelte):
`stores.ts`:
```ts
import { createStore } from 'tepkijs-client';
import type { TepkiStore } from 'tepkijs-client';

type State = {
messages: string[]
}

export const store: TepkiStore = createStore('room-01', 'http://localhost:5000');
```
```svelte

import { store } from './stores';

let message = '';

function sendMessage() {
store.call('addMessage', message);
message = '';
}

{#if $store.isConnected}


    {#each $store.messages as message}
  • {message}

  • {/each}



Send
{/if}

```