Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/ryota-ka/cycle-ink-driver

Ink driver for Cycle.js
https://github.com/ryota-ka/cycle-ink-driver

cyclejs ink

Last synced: 2 days ago
JSON representation

Ink driver for Cycle.js

Awesome Lists containing this project

README

        

# cycle-ink-driver

[![npm](https://img.shields.io/npm/v/cycle-ink-driver.svg)](https://www.npmjs.com/package/cycle-ink-driver) [![CircleCI](https://circleci.com/gh/ryota-ka/cycle-ink-driver/tree/master.svg?style=shield)](https://circleci.com/gh/ryota-ka/cycle-ink-driver/tree/master)

[Ink](https://github.com/vadimdemedes/ink) driver for [Cycle.js](https://cycle.js.org/)

## Example

```typescript
/** @jsx createIncorporatedElement */

import { ReactSource } from '@cycle/react';
import { run } from '@cycle/run';
import { createIncorporatedElement, makeInkDriver } from 'cycle-ink-driver';
import { Box } from 'ink';
import TextInput from 'ink-text-input';
import { Stream } from 'xstream';

const sels = {
name: Symbol('name'),
};

function View({ name }: { name: string }): JSX.Element {
return (


Name: {}} />

{'-'.repeat(20)}
Hello {name}

);
}

function main({ react }: { react: ReactSource }): { react: Stream } {
const name$ = react.select(sels.name).events('change').startWith('');

const view$ = name$.map((name) => View({ name }));

return {
react: view$,
};
}

const drivers = {
react: makeInkDriver(),
};

run(main, drivers);
```

![screencast](./docs/screencast.gif)