-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,30 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
#include <variant> | ||
#include <spaic/VNode.hpp> | ||
#include <spaic/Property.hpp> | ||
#include <spaic/State.hpp> | ||
|
||
namespace spaic::comp | ||
{ | ||
using ShouldRender = bool; | ||
template <typename State, typename Msg> | ||
using Update = std::function(Msg)->ShouldRender; | ||
using Update = std::function<ShouldRender()>; | ||
using Render = std::function<spaic::vnode::VNode()>; | ||
|
||
template <typename Props, typename State> | ||
class ComponentBody; | ||
template <typename Props> | ||
class Component | ||
{ | ||
public: | ||
template <typename... T> | ||
ComponentBody operator()(T... args) noexcept; | ||
}; | ||
template <typename Props, typename State> | ||
Component<Props, State> create_component(Props props, State state); | ||
} // namespace spaic | ||
class ComponentBody | ||
{ | ||
public: | ||
spaic::vnode::VNode operator()(spaic::vnode::VNode children...) noexcept; | ||
}; | ||
template <typename Props, typename StateSet> | ||
Component<Props> create_component(Props props, StateSet state, Update update, Render render); | ||
} // namespace spaic::comp |
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 |
---|---|---|
|
@@ -7,5 +7,8 @@ class State | |
{ | ||
public: | ||
State() {} | ||
|
||
// todo: | ||
T &operator*(); | ||
}; | ||
} // namespace spaic::state |
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,30 @@ | ||
#pragma once | ||
|
||
#include <variant> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace spaic::vnode | ||
{ | ||
using VNode = std::variant< | ||
std::string, | ||
std::nullptr_t, | ||
bool, | ||
short, | ||
unsigned short, | ||
int, | ||
unsigned int, | ||
long, | ||
unsigned long, | ||
long long, | ||
unsigned long long, | ||
char, | ||
signed char, | ||
unsigned char, | ||
wchar_t, | ||
char16_t, | ||
char32_t, | ||
float, | ||
double, | ||
long double>; | ||
} // namespace spaic::vnode |