0.0.28 • Published 1 year ago

x-shard v0.0.28

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

x-shard

GitHub

An event-driven tool that describes behavior relies on either domain or browser events. x-shard is a framework-agnostic tool that operates within the web environment, adhering to its standards.

yarn add x-shard
const $auth = createStore<{ session?: Session; logger?: Logger }>();

const session_defined = createEvent<Session>();

$auth.on('window:offline' , () => { /* do something */ })

$auth.on(session_defined, (store, payload) => {
    store.session = wrap(payload, $another_store.get().wallet);
    store.logger = new Logger();

    another_event(store.session?.id);
});

// subsequence events batches in one process so .track will be triggered once
$auth.track((snapshot) => {
    snapshot.logger?.stdout('session has been certificated');
});

session_defined(session); // emit domain event

React Bind

yarn add x-shard-react
const $main = createStore({ counter: 5 });
const incremented = createEvent();

$main.on(incremented, (store) => {
    store.counter += 1;
});
$main.on('document:DOMContentLoaded', (store) => {
    store.counter += 10;
});

function App() {
    const $ = useStore($main);
    return (
        <button onClick={() => incremented()}>count</button>
    )
}
0.0.28

1 year ago

0.0.20

1 year ago

0.0.21

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.19

1 year ago

0.0.16

1 year ago

0.0.17

1 year ago

0.0.18

1 year ago

0.0.15

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.14

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.1

1 year ago