Home Reference Source Repository

Function

Static Public Summary
public

createBuilder(target: string, rocBuilder: rocBuilder, resolver: string): rocBuilder

Creates a builder.

public

Client entry point for React applications.

public

createReduxStore(reducers: object, middlewares: ...function): function

Redux store creator

public

Route creator

public

getResolvePath(resolvePaths: ...string): string

Used on the server to find all dependecies.

public

Read stats from build

public

useReact(createServer: function): function

Enhances a server instance with React support.

Static Public

public createBuilder(target: string, rocBuilder: rocBuilder, resolver: string): rocBuilder source

import createBuilder from 'roc-web-react/lib/builder/index.js'

Creates a builder.

Params:

NameTypeAttributeDescription
target string
  • nullable: false

a target: should be either "client" or "server"

rocBuilder rocBuilder

A rocBuilder to base everything on.

resolver string
  • optional
  • default: roc-web-react/lib/helpers/get-resolve-path
  • nullable: false

Path to the resolver for the server side getResolvePath

Return:

rocBuilder

public createClient(options: rocClientOptions) source

import createClient from 'roc-web-react/src/app/client/index.js'

Client entry point for React applications.

Params:

NameTypeAttributeDescription
options rocClientOptions

Options for the client

Example:

import { createClient } from 'roc-web-react/app/client';

const server = createClient({
    createRoutes: routes,
    createStore: store,
    mountNode: 'application'
});

public createReduxStore(reducers: object, middlewares: ...function): function source

import {createReduxStore} from 'roc-web-react/src/app/shared/flux/create-store.js'

Redux store creator

Params:

NameTypeAttributeDescription
reducers object
  • nullable: false

Reducers that should be added to the store

middlewares ...function

Redux middlewares that should be added to the store

Return:

function

A function that has the following interface: (callback) => (reduxReactRouter, getRoutes, createHistory, initialState). The callback will be called when the application is in DEV mode on the client as a way to add hot module update of the reducers. The callback itself will take a function as the parameter that in turn takes the reducers to update.

public createRoutes(routes: function): function source

Route creator

Params:

NameTypeAttributeDescription
routes function
  • nullable: false

A function that takes a reference to potential store and returns a React Router route

Return:

function

A function that takes a reference to a potential store, runs the routes function and wrapps the result in a Application component wrapper. See the README.md for more information on what it does.

public getResolvePath(resolvePaths: ...string): string source

Used on the server to find all dependecies.

When creating a extension of this project this needs to be extended.

Params:

NameTypeAttributeDescription
resolvePaths ...string

Paths to be resolved.

Return:

string

Path that can be used with Module._initPaths().

public readStats(stats: string): object source

Read stats from build

Params:

NameTypeAttributeDescription
stats string

Path to a stats file from the client build

Return:

object

The stats object in the stats file

public useReact(createServer: function): function source

Enhances a server instance with React support.

Extends the options object from roc-web. See rocServerOptions for what the new options are.

Params:

NameTypeAttributeDescription
createServer function

A createServer function to wrap and add extra functionallity to

Return:

function

Returns a new createServer that can be used to create server instances that can manage React applications

Example:

import { createServer } from 'roc-web/app';
import { useReact } from 'roc-web-react/app/server';

const server = useReact(createServer)({
    serve: 'files',
    createRoutes: routes,
    createStore: store,
    stats: './stats.json'
});

server.start();