# createSignal

```ts
function createSignal<T, TClose = never>(): Signal<T, TClose>
```

Create a new [Signal](https://frontside.com/effection/api/v4-next/Signal.md)

Signal should be used when you need to send messages to a stream
from _outside_ of an operation. The most common case of this is to
connect a plain, synchronous JavaScript callback to an operation.

### Examples
#### Example 1
```javascript
function* logClicks(button) {
  let clicks = createSignal<MouseEvent>();
  try {
    button.addEventListener("click", clicks.send);

    for (let click of yield* each(clicks)) {
      console.log("click", click);
    }
   } finally {
     button.removeEventListener("click", clicks.send);
   }
}
```

Do not use a signal to send messages from within an operation as it could
result in out-of-scope code being executed. In those cases, you should use a
[Channel](https://frontside.com/effection/api/v4-next/Channel.md).
---
### Type Parameters
T


TClose = never


### Return Type


[Signal](https://frontside.com/effection/api/v4-next/Signal.md)&lt;T, TClose&gt;

[View code](https://github.com/thefrontside/effection/tree/effection-v4.2.0/lib/signal.ts#L119)
