-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Luau types for thunks and the store (#71)
Follows up on the types added in: #70. Adds Luau types for thunks and the store. This is partially inspired by upstream Redux types here and here, but modified to be as useful as possible given Luau's constraints.
- Loading branch information
1 parent
07f634e
commit ce63e3d
Showing
22 changed files
with
142 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"languageMode": "nonstrict", | ||
"lint": { "*": true }, | ||
"lintErrors": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--!strict | ||
--[[ | ||
Create a composite reducer from a map of keys and sub-reducers. | ||
]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--!strict | ||
--[[ | ||
A helper function to define a Rodux action creator with an associated name. | ||
]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--!strict | ||
export type Action<Type = any> = { | ||
type: Type, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--!strict | ||
local actions = require(script.Parent.actions) | ||
|
||
type AnyAction = actions.AnyAction | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,22 @@ | ||
--!strict | ||
local actions = require(script.Parent.actions) | ||
|
||
type BaseAction = actions.Action<string> | ||
|
||
type EmptyObject = {} | ||
|
||
export type CombinedState<State> = EmptyObject & State | ||
|
||
export type IDispatch<Store> = <Action>(self: Store, action: Action & BaseAction) -> () | ||
export type Dispatch<State = any> = IDispatch<Store<State>> | ||
|
||
export type IStore<State, Dispatch> = { | ||
dispatch: Dispatch, | ||
getState: (self: IStore<State, Dispatch>) -> State, | ||
destruct: (self: IStore<State, Dispatch>) -> (), | ||
flush: (self: IStore<State, Dispatch>) -> (), | ||
changed: RBXScriptSignal, | ||
} | ||
export type Store<State = any> = IStore<State, Dispatch<State>> | ||
|
||
return nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--!strict | ||
local store = require(script.Parent.store) | ||
|
||
type IStore<State, Dispatch> = store.IStore<State, Dispatch> | ||
type IDispatch<Store> = store.IDispatch<Store> | ||
|
||
export type IThunkAction<ReturnType, Store> = (store: Store) -> ReturnType | ||
export type ThunkAction<ReturnType, State = any> = IThunkAction<ReturnType, ThunkfulStore<State>> | ||
|
||
export type IThunkDispatch<Store> = <ReturnType>( | ||
self: Store, | ||
thunkAction: IThunkAction<ReturnType, Store> | ||
) -> ReturnType | ||
export type ThunkDispatch<State = any> = IDispatch<ThunkfulStore<State>> & IThunkDispatch<ThunkfulStore<State>> | ||
|
||
export type ThunkfulStore<State = any> = IStore<State, ThunkDispatch<State>> | ||
|
||
return nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
declare function afterAll(callback: () -> ()): () | ||
declare function afterEach(callback: () -> ()): () | ||
|
||
declare function beforeAll(callback: () -> ()): () | ||
declare function beforeEach(callback: () -> ()): () | ||
|
||
declare function describe(phrase: string, callback: () -> ()): () | ||
declare function describeFOCUS(phrase: string, callback: () -> ()): () | ||
declare function fdescribe(phrase: string, callback: () -> ()): () | ||
declare function describeSKIP(phrase: string, callback: () -> ()): () | ||
declare function xdescribe(phrase: string, callback: () -> ()): () | ||
|
||
declare function expect(value: any): any | ||
|
||
declare function FIXME(optionalMessage: string?): () | ||
declare function FOCUS(): () | ||
declare function SKIP(): () | ||
|
||
declare function it(phrase: string, callback: () -> ()): () | ||
declare function itFOCUS(phrase: string, callback: () -> ()): () | ||
declare function fit(phrase: string, callback: () -> ()): () | ||
declare function itSKIP(phrase: string, callback: () -> ()): () | ||
declare function xit(phrase: string, callback: () -> ()): () | ||
declare function itFIXME(phrase: string, callback: () -> ()): () |