> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# RealSignal.Connect

> Connects a callback to a RealSignal and returns a RealSignalConnection. The callback receives the arguments passed to Fire.

<div className="real-function-page">
  ```lua theme={null}
  RealSignal.Connect(signal: RealSignal, callback: (....any) -> ()): RealSignalConnection
  ```

  ## Arguments

  <ParamField path={"signal"} type={"RealSignal"} required>
    Signal object returned by Signal.new.
  </ParamField>

  <ParamField path={"callback"} type={"(....any) -> ()"} required>
    Function called whenever the signal is fired while the connection remains connected.
  </ParamField>

  ## Returns

  <ResponseField name={"connection"} type={"RealSignalConnection"}>
    Connection object with Disconnect.
  </ResponseField>

  ## Types

  ### RealSignal

  Signal object returned by Signal.new.

  | Name | Type | Required | คำอธิบาย |
  | - | - | - | - |
  | `Connect` | `(callback: (...any) -> ()) -> RealSignalConnection` | Yes | Adds a callback that runs when Fire is called. |
  | `Once` | `(callback: (...any) -> ()) -> RealSignalConnection` | Yes | Adds a callback that is disconnected before its first callback invocation. |
  | `Wait` | `() -> ...any` | Yes | Yields until Fire resumes the waiter with the fired values. |
  | `Fire` | `(...values: any) -> ()` | Yes | Runs connected callbacks and resumes waiters with the provided values. |

  ### RealSignalConnection

  Connection object returned by RealSignal.Connect and RealSignal.Once.

  | Name | Type | Required | คำอธิบาย |
  | - | - | - | - |
  | `Disconnect` | `() -> ()` | Yes | Disconnects the connection. |

  ## ตัวอย่าง

  Connect a callback and disconnect it when it is no longer needed.

  ```lua theme={null}
  local signal = Signal.new()

  local connection = signal:Connect(function(value)
      print(value)
  end)

  signal:Fire(1)
  connection:Disconnect()
  ```
</div>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.