# What Does Ferp Provide

## app()

This is the entry point to your application. An application can be describe in three pieces, `init`, `subscribe`, and `observe`. Init is a **required** tuple of your initial data in the form of `[initialState, initialEffect]`. Subscribe is an **optional** function with the signature `(state) => [sub1, sub2, ...]`. Observe is an **optional** function with the signature `([currentState, currentEffect], action) => {}` and is used for debugging. These pieces all exist inside an object, and all together, they may look something like this:

{% code title="example.js" %}

```javascript
import { app, effects } from 'ferp';



const initialState = 1;

const Add = state => [state + 1, effects.none()];

const addSubcription = (dispatch, intervalInMs) => {
  const handle = setInterval(dispatch, intervalInMs, effects.act(Add));
  
  return () => {
    clearInterval(handle);
  };
};

const dispatch = app({
  init: [
    initialState,
    effects.none(),
  ],

  subscribe: (state) => [
    state < 10 && [addSubscription, 1000],
  ],
});
```

{% endcode %}

Don't worry if this looks scary, this guide will step you through each piece, and explain how they work.

Your call to app will also return a copy of dispatch. This is meant to be an escape hatch, but in all likelihood, you will never need it. If you're not sure if you need it, check out the [What is a Ferp Subscription?](/understanding-subscriptions-in-ferp/what-is-a-ferp-subscription.md) which covers 99% of the cases when you think you may need the app global dispatch method. The last 1% is probably for end-to-end testing of your application

## effects {}

Ferp, inspired by the likes of Elm's Cmd, exports a set of core effects that can be combined and composed to build powerful pieces of logic. Getting comfortable and familiar with these effects will enable you to use Ferp effectively.

Effects are a way to encapsulate code that affects out-of-app state. These are things like getting the system time, requesting permissions, accessing the file system, or handling user interaction.

There are a set of core effects that Ferp exposes as the effects object:

```javascript
import { effects } from 'ferp';

console.log(effects);
/*
{ none: [Function: none],
  batch: [Function: p],
  defer: [Function: q],
  thunk: [Function: r],
  act: [Function: s] }
*/
```

There are some other effects in that object, but we're not going to dive into those as much right here. Check out the [core effects](/understanding-effects-in-ferp/core-effects.md) documentation for more information!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ferp.mrbarry.com/getting-started/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
