Skip to main content

Slinker provide a single one to one event, we call it a link.

A link can only have a single sender and a single reciver.

The source code is locate at github .

Build Status

Introduction

Link receiver can subscribe to specific link. A reciver function required a sender argument, and a keyworld argument which is optional.

>>> from slinker import Namespace
>>> links = Namespace()
>>> started = links.link('round-started')
>>> def each(round):
...     print "Round %s!" % round
...
>>> started.connect(each)
>>> for round in range(1, 4):
...     started.send(round)
...
Round 1!
Round 2!
Round 3!

Here provide a decorator receiver which can be used for connect. Because a link can only have one reciever. If you want to connect to another receiver, you must disconnect the formly receiver.

>>> started.disconnect(each)
>>> from slinker import receiver
>>> @receiver(started)
    def test(sender, **kwargs):
...     return sender
>>> func, result = started.send('hello')
>>> func == test
... True
>>> result == 'hello'
...  True

More examples

see the tests directory.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slinker-0.1.tar.gz (6.7 kB view details)

Uploaded Source

File details

Details for the file slinker-0.1.tar.gz.

File metadata

  • Download URL: slinker-0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for slinker-0.1.tar.gz
Algorithm Hash digest
SHA256 3500ee34aa1a41ef6de19fe626e784ef0d9fc587cac2b6acf96989b3c3e52d9d
MD5 f1455eb187c431e69029ade8bae86060
BLAKE2b-256 44592291d0a130b960d8b98e5405b8bb7e118f55ff5d7a340824d01523e9f98a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page