Skip to content

Releases: beekai-oss/little-state-machine

Version 3.1.2

20 Oct 05:11
Compare
Choose a tag to compare

fix: added check for disabled session storage (#58)

Version 3.1.1

29 Jul 00:16
Compare
Choose a tag to compare

revert async store update

Version 3.1.0

28 Jul 06:05
Compare
Choose a tag to compare
  • fix syncStorage doesn't work with react-native #48
    • now support aysnc store retrieve.

Version 3.0.3

09 Jul 09:52
Compare
Choose a tag to compare

fix Error on SSR projects with actions execution #45

Version 3.0.2

27 May 00:59
Compare
Choose a tag to compare
  • include ie11 build

Version 3.0.1

18 May 12:27
Compare
Choose a tag to compare
  • fix #38 middle not return value issue

Version 3.0.0

06 May 07:15
Compare
Choose a tag to compare

Version 2.14.0

23 Apr 10:08
Compare
Choose a tag to compare

Middlewares all call same data object - would like it to act as a pipe. #31
Exported type for action expects store. #30

Version 2.13.0

24 Mar 03:04
Compare
Choose a tag to compare
  • support multiple store sync
createStore({
  yourDetail, // it's an object of your state { firstName: '', lastName: '' }
}, {
  syncStores : [
     { 
       externalStoreName: 'externalStoreName',
       transform: ({ externalStoreData, currentStoreData }) => {
         return { ...externalStoreData, ...currentStoreData };
        },
     }
  ]
})

Version 2.12.0

17 Mar 06:30
Compare
Choose a tag to compare

🥂 compatible with React Native

Example code below:

import React from "react";
import { TextInput, Button, View, AsyncStorage } from "react-native";
import {
  StateMachineProvider,
  createStore,
  setStorageType,
  useStateMachine
} from "little-state-machine";
import { useForm, Controller } from "react-hook-form";
import * as yup from "yup";

setStorageType(AsyncStorage);

createStore({});

function update(state, payload) {
  return {
    ...state,
    ...payload
  };
}

let counter = 0;

const Form = () => {
  const { handleSubmit, control, errors } = useForm({
    validationSchema: yup.object().shape({
      firstName: yup
        .string()
        .label("Name")
        .required()
    })
  });
  const { action, state } = useStateMachine(update);

  const onSubmit = formData => {
    action(formData);
  };

  const onChange = args => {
    return {
      value: args[0].nativeEvent.text
    };
  };
  
  counter++;

  return (
    <View style={{ marginTop: 40 }}>
      <Controller
        as={
          <TextInput
            style={{ borderWidth: 1, height: 80 }}
            placeholder="your name"
          />
        }
        control={control}
        name="firstName"
        onChange={onChange}
        defaultValue={state.firstName}
      />
      <Controller
        as={<TextInput style={{ borderWidth: 1, height: 80 }} />}
        control={control}
        name="lastName"
        onChange={onChange}
        defaultValue={state.lastName}
      />
      <Button title="Submit" onPress={handleSubmit(onSubmit)} />
    </View>
  );
};

const App = () => (
  <StateMachineProvider>
    <Form />
  </StateMachineProvider>
);

export default App;