connector()

Create a connector from a generator function.

Usage

Source

connector(fn)

The decorated function should yield Document instances.

Parameters

fn: Callable[[], Iterator[Document]]
A callable that returns an iterator of documents.

Returns

Connector
A connector wrapping the function.

Examples

import talk_box as tb

@tb.connector
def my_source():
    yield tb.Document(title="hello", content="world")

for doc in my_source.scan():
    print(doc.title)