Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to rescript #75

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove legacy stuff
amiralies committed Jul 29, 2021
commit 8b36c6bc9b457070ba28f9deb52b90e95beffe70
17 changes: 0 additions & 17 deletions src/context.bs.js

This file was deleted.

173 changes: 0 additions & 173 deletions src/reductive.bs.js

This file was deleted.

65 changes: 0 additions & 65 deletions src/reductive.res
Original file line number Diff line number Diff line change
@@ -39,71 +39,6 @@ module Store = {
let replaceReducer = (store, reducer) => store.reducer = reducer
}

/* deprecated, use hooks API instead */
module Lense = {
type state<'reductiveState> = {
reductiveState: option<'reductiveState>,
unsubscribe: option<unit => unit>,
}
type rec action =
| UpdateState
| AddListener(action => unit)
let createMake = (~name="Lense", ~lense: 'state => 'lense, store: Store.t<'action, 'state>) => {
let innerComponent = ReasonReact.reducerComponent(name)
let make = (
~component: (
~state: 'lense,
~dispatch: 'action => unit,
array<ReasonReact.reactElement>,
) => ReasonReact.component<'a, 'b, 'c>,
_children: array<ReasonReact.reactElement>,
): ReasonReact.component<state<'lense>, ReasonReact.noRetainedProps, action> => {
...innerComponent,
initialState: () => {
reductiveState: Some(lense(Store.getState(store))),
unsubscribe: None,
},
reducer: (action, state) =>
switch action {
| AddListener(send) =>
ReasonReact.Update({
unsubscribe: Some(Store.subscribe(store, _ => send(UpdateState))),
reductiveState: Some(lense(Store.getState(store))),
})
| UpdateState =>
lense(Store.getState(store))
->Some
->Belt.Option.eq(state.reductiveState, (a, b) => a === b)
? ReasonReact.NoUpdate
: ReasonReact.Update({
...state,
reductiveState: Some(lense(Store.getState(store))),
})
},
didMount: ({send}) => send(AddListener(send)),
willUnmount: ({state}) =>
switch state.unsubscribe {
| Some(unsubscribe) => unsubscribe()
| None => ()
},
render: ({state}) =>
switch state.reductiveState {
| None => ReasonReact.null
| Some(state) => ReasonReact.element(component(~state, ~dispatch=Store.dispatch(store), []))
},
}
make
}
}

/* deprecated, use provider from reductiveContext.re */
module Provider = {
type state<'reductiveState> = Lense.state<'reductiveState>
type action = Lense.action
let createMake = (~name="Provider", store: Store.t<'action, 'state>) =>
Lense.createMake(~name, ~lense=s => s, store)
}

/* ** These are all visible apis of Redux that aren't needed in Reason.
* When used, build tools will provide explanation of alternatives.
* (see .rei for those)
37 changes: 0 additions & 37 deletions src/reductive.resi
Original file line number Diff line number Diff line change
@@ -15,43 +15,6 @@ module Store: {
let replaceReducer: (t<'action, 'state>, ('state, 'action) => 'state) => unit
}

module Lense: {
type state<'reductiveState>
type rec action =
| UpdateState
| AddListener(action => unit)

@deprecated("Legacy API, prefer the new hooks API with jsx 3")
let createMake: (
~name: string=?,
~lense: 'state => 'lense,
Store.t<'action, 'state>,
~component: (
~state: 'lense,
~dispatch: 'action => unit,
array<ReasonReact.reactElement>,
) => ReasonReact.component<'a, 'b, 'c>,
array<ReasonReact.reactElement>,
) => ReasonReact.component<state<'lense>, ReasonReact.noRetainedProps, action>
}

module Provider: {
type state<'reductiveState> = Lense.state<'reductiveState>
type action = Lense.action

@deprecated("Legacy API, prefer the new hooks API with jsx 3")
let createMake: (
~name: string=?,
Store.t<'action, 'state>,
~component: (
~state: 'state,
~dispatch: 'action => unit,
array<ReasonReact.reactElement>,
) => ReasonReact.component<'a, 'b, 'c>,
array<ReasonReact.reactElement>,
) => ReasonReact.component<state<'state>, ReasonReact.noRetainedProps, action>
}

/* ** These are all visible apis of Redux that aren't needed in Reason.
* When used, build tools will provide explanation of alternatives.
*/